:root {
  --brand: #2F6BFF;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #8a94a6;
  --line: #e6eaf2;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* 顶部 */
.hd {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.hd-avatar {
  width: 38px; height: 38px; border-radius: 12px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; flex: none;
}
.hd-main { flex: 1; min-width: 0; }
.hd-name { font-weight: 600; font-size: 15px; }
.hd-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c3cad8; display: inline-block; }
.dot.on { background: #22c55e; }
.dot.off { background: #ef4444; }
.hd-close {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
}

/* 消息区 */
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 4px; -webkit-overflow-scrolling: touch; }
.msg { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.msg .bubble {
  max-width: 76%; padding: 9px 12px; border-radius: 14px; background: var(--card);
  box-shadow: 0 1px 2px rgba(16,24,40,.06); word-break: break-word; white-space: pre-wrap;
}
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.other .bubble { border-bottom-left-radius: 4px; }
.msg .time { font-size: 11px; color: var(--muted); align-self: flex-end; margin: 0 4px 2px; flex: none; }
.msg.sys { justify-content: center; }
.msg.sys .bubble {
  background: rgba(26,34,51,.06); color: var(--muted); font-size: 12px;
  box-shadow: none; border-radius: 999px; padding: 4px 12px; max-width: 90%; text-align: center;
}
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { font-size: 40px; }
.empty-text { margin-top: 8px; font-size: 14px; }

/* 输入区 */
.ft { background: var(--card); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.ft-banner { font-size: 12px; color: #b45309; background: #fff7ed; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
#input {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; max-height: 120px; outline: none; background: #fafbff;
}
#input:focus { border-color: var(--brand); background: #fff; }
.send {
  border: none; background: var(--brand); color: #fff; border-radius: 12px;
  padding: 10px 16px; font: inherit; font-weight: 600; flex: none;
}
.send:disabled { opacity: .45; }

/* 遮罩 */
.mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex;
  align-items: center; justify-content: center; z-index: 20; backdrop-filter: blur(2px);
}
.mask-box { background: #fff; padding: 24px 22px; border-radius: 16px; text-align: center; max-width: 78vw; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid #e5e9f2; border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mask-btn { margin-top: 14px; border: none; background: var(--brand); color: #fff; padding: 8px 18px; border-radius: 10px; font: inherit; }
