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

html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #1f2329;
  background: #f5f6f7;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== 顶栏 ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e5e6eb;
  flex-shrink: 0;
}

.chat-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-text {
  font-size: 12px;
  color: #8f959e;
  margin-top: 2px;
}
.status-text.error { color: #f54a45; }

.chat-select {
  max-width: 45%;
  padding: 4px 6px;
  border: 1px solid #dee0e3;
  border-radius: 6px;
  background: #fff;
}

/* ===== 消息区 ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 88%; display: flex; flex-direction: column; gap: 3px; }
.msg .meta { font-size: 11px; color: #8f959e; }
.msg .bubble {
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.customer { align-self: flex-start; }
.msg.customer .bubble { background: #fff; border: 1px solid #e5e6eb; border-top-left-radius: 2px; }

.msg.agent { align-self: flex-end; align-items: flex-end; }
.msg.agent .bubble { background: #d6e9ff; border-top-right-radius: 2px; }

/* ===== 建议话术面板 ===== */
.panel {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e5e6eb;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.suggest-title { font-weight: 600; }

.link-btn {
  border: none;
  background: none;
  color: #0082ef;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.card {
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.card:hover { border-color: #0082ef; background: #f5f9ff; }
.card .text { line-height: 1.5; margin-bottom: 6px; }
.card .ops { display: flex; gap: 12px; justify-content: flex-end; }
.card .ops button {
  border: none;
  background: none;
  font-size: 12px;
  cursor: pointer;
  color: #8f959e;
  padding: 0;
}
.card .ops button.send { color: #0082ef; font-weight: 600; }

.typing { color: #8f959e; font-size: 13px; padding: 6px 2px; }

.draft {
  width: 100%;
  resize: none;
  border: 1px solid #dee0e3;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  line-height: 1.5;
}
.draft:focus { outline: none; border-color: #0082ef; }

.actions { display: flex; gap: 8px; justify-content: flex-end; }

.btn {
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn.primary { background: #0082ef; color: #fff; }
.btn.primary:active { background: #006fd6; }
.btn.ghost { background: #fff; border-color: #dee0e3; color: #1f2329; }

/* ===== 其他 ===== */
.empty-hint {
  color: #8f959e;
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 40%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .75);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 99;
  max-width: 80%;
}
