/* ============================================================
   对话建站 H5 - 移动端聊天样式
   ============================================================ */
:root {
  --h5-primary: #1e6f9f;
  --h5-teal: #0d9488;
  --h5-bg: #eef3f7;
  --h5-bot: #ffffff;
  --h5-user: #1e6f9f;
  --h5-text: #16283a;
  --h5-text-2: #5b7488;
  --h5-line: #e2e8f0;
  --h5-safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
/* hidden 属性必须优先生效，避免登录框/预览/聊天区残留 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--h5-bg); color: var(--h5-text);
  display: flex; flex-direction: column; height: 100%; height: 100dvh;
  overflow: hidden;
}

/* 顶部导航 */
.h5-nav {
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--h5-primary), var(--h5-teal));
  color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.h5-nav-brand { font-size: 17px; font-weight: 700; }
.h5-nav-status { font-size: 12px; opacity: .9; }

/* 登录 */
.h5-login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.h5-login-card {
  width: 100%; max-width: 340px; background: #fff; border-radius: 18px;
  padding: 32px 24px; box-shadow: 0 16px 40px rgba(15,37,55,.12); text-align: center;
}
.h5-login-icon { font-size: 40px; }
.h5-login-card h1 { font-size: 19px; margin-top: 8px; }
.h5-login-sub { font-size: 13px; color: var(--h5-text-2); margin: 6px 0 20px; }
.h5-field { display: block; text-align: left; margin-bottom: 14px; }
.h5-field span { font-size: 12.5px; color: var(--h5-text-2); font-weight: 600; }
.h5-field input {
  width: 100%; margin-top: 5px; padding: 11px 12px;
  border: 1px solid var(--h5-line); border-radius: 10px; font-size: 15px;
}
.h5-field input:focus { outline: none; border-color: var(--h5-primary); }
.h5-error { background: #fdecec; color: #dc2626; font-size: 13px; padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; }
.h5-login-tip { font-size: 12px; color: var(--h5-text-2); margin-top: 14px; }

/* 聊天 */
.h5-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.h5-msgs { flex: 1; overflow-y: auto; padding: 16px 12px 8px; -webkit-overflow-scrolling: touch; }

.h5-row { display: flex; margin-bottom: 14px; align-items: flex-end; }
.h5-row.bot { justify-content: flex-start; }
.h5-row.user { justify-content: flex-end; }
.h5-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: #fff; border: 1px solid var(--h5-line);
}
.h5-row.user .h5-avatar { display: none; }
.h5-bubble {
  max-width: 76%; padding: 10px 13px; border-radius: 14px; font-size: 15px;
  line-height: 1.55; word-break: break-word; white-space: pre-wrap;
}
.h5-row.bot .h5-bubble {
  background: var(--h5-bot); color: var(--h5-text);
  border-bottom-left-radius: 4px; margin-left: 8px;
  box-shadow: 0 1px 2px rgba(15,37,55,.05);
}
.h5-row.user .h5-bubble {
  background: var(--h5-user); color: #fff;
  border-bottom-right-radius: 4px; margin-right: 0;
}
.h5-bubble img { max-width: 100%; border-radius: 8px; display: block; margin-top: 6px; }
.h5-bubble a { color: inherit; text-decoration: underline; }
.h5-sitecard {
  margin-top: 8px; background: #f0f9f7; border: 1px solid #bfe6df;
  border-radius: 10px; padding: 10px 12px;
}
.h5-sitecard .sc-label { font-size: 11px; color: #0f766e; font-weight: 700; }
.h5-sitecard .sc-url { font-size: 14px; font-weight: 700; color: #0f766e; word-break: break-all; margin-top: 3px; }
.h5-sitecard .sc-open { display: inline-block; margin-top: 6px; font-size: 12px; color: #fff; background: var(--h5-teal); padding: 4px 12px; border-radius: 999px; text-decoration: none; }

/* 正在输入动效 */
.h5-typing { display: flex; align-items: center; gap: 4px; padding: 0 16px 10px; }
.h5-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b6c6d3; animation: h5Blink 1.2s infinite; }
.h5-typing span:nth-child(2) { animation-delay: .2s; }
.h5-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes h5Blink { 0%,80%,100%{opacity:.3;} 40%{opacity:1;} }

/* 输入区 */
.h5-inputbar {
  flex: 0 0 auto; background: #fff; border-top: 1px solid var(--h5-line);
  padding: 8px 10px calc(8px + var(--h5-safe-bottom));
}
.h5-input-row { display: flex; align-items: center; gap: 8px; }
.h5-iconbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--h5-line);
  background: #fff; font-size: 18px; flex: 0 0 38px;
}
.h5-textinput {
  flex: 1; height: 38px; border: 1px solid var(--h5-line); border-radius: 19px;
  padding: 0 14px; font-size: 15px; background: #f4f7fa;
}
.h5-textinput:focus { outline: none; border-color: var(--h5-primary); }
.h5-sendbtn {
  height: 38px; padding: 0 16px; border: 0; border-radius: 19px;
  background: var(--h5-primary); color: #fff; font-size: 15px; font-weight: 600;
}
.h5-sendbtn:disabled { opacity: .5; }
.h5-btn { display: block; width: 100%; height: 44px; border: 0; border-radius: 12px; font-size: 16px; font-weight: 600; }
.h5-btn-primary { background: var(--h5-primary); color: #fff; }

/* 多图预览 */
.h5-preview { margin-top: 8px; position: relative; }
.h5-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.h5-thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; background: #eef2f5; flex: 0 0 auto; }
.h5-thumb img { width: 100%; height: 100%; object-fit: cover; }
.h5-thumb-prog { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); color: #fff; font-size: 12px; font-weight: 700; }
.h5-thumb-done { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: #0d9488; color: #fff; font-size: 11px; display: none; align-items: center; justify-content: center; }
.h5-thumb.is-done .h5-thumb-done { display: flex; }
.h5-thumb-err { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(214,69,69,.75); color: #fff; font-size: 18px; font-weight: 700; }
.h5-thumb.is-error .h5-thumb-err { display: flex; }
.h5-thumb-x { position: absolute; top: 0; right: 0; width: 18px; height: 18px; border: 0; border-radius: 0 0 0 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 1; cursor: pointer; }
.h5-imgcount { min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--h5-primary); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }

@media (min-width: 640px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--h5-line); }
}

/* ============================================================
   录音状态
   ============================================================ */
.h5-iconbtn.recording { background: var(--h5-primary); border-color: var(--h5-primary); }

.h5-rec {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--h5-line); border-radius: 16px;
  padding: 16px 20px; width: 240px; text-align: center;
  box-shadow: 0 10px 30px rgba(15,37,55,.18); z-index: 50;
}
.h5-wave { display: flex; align-items: center; justify-content: center; gap: 4px; height: 26px; }
.h5-wave span {
  width: 4px; height: 8px; border-radius: 2px; background: var(--h5-primary);
  animation: h5Wave 1s ease-in-out infinite;
}
.h5-wave span:nth-child(1) { animation-delay: 0s; }
.h5-wave span:nth-child(2) { animation-delay: .15s; }
.h5-wave span:nth-child(3) { animation-delay: .3s; }
.h5-wave span:nth-child(4) { animation-delay: .45s; }
.h5-wave span:nth-child(5) { animation-delay: .3s; }
.h5-wave span:nth-child(6) { animation-delay: .15s; }
.h5-wave span:nth-child(7) { animation-delay: 0s; }
@keyframes h5Wave { 0%,100%{height:8px;} 50%{height:24px;} }
.h5-rec-timer { font-size: 18px; font-weight: 700; color: var(--h5-text); margin-top: 8px; font-variant-numeric: tabular-nums; }
.h5-rec-tip { font-size: 12px; color: var(--h5-text-2); margin-top: 6px; }

.h5-rec-partial {
  min-height: 20px; margin-top: 6px; font-size: 14px; color: var(--h5-primary);
  font-weight: 600; line-height: 1.4; max-height: 60px; overflow: hidden;
}

/* 登录：验证码行 */
.h5-code-row { display: flex; gap: 8px; align-items: center; }
.h5-code-row input { flex: 1; min-width: 0; }
.h5-codebtn {
  flex: 0 0 auto; height: 40px; padding: 0 12px; border: 1px solid var(--h5-primary);
  background: #fff; color: var(--h5-primary); border-radius: 10px; font-size: 13px; white-space: nowrap;
}
.h5-codebtn:disabled { opacity: .5; }
.h5-error.ok { color: #0d9488; background: rgba(13,148,136,.1); }
