* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #d9dde2;
  color: #111827;
}
.shell {
  height: 100vh;
  display: block;
  padding: 12px;
  overflow: hidden;
}
.wechat {
  min-width: 0;
  height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #c7cdd6;
  border-radius: 4px;
  background: #ededed;
}
.chat-header {
  flex: 0 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #d6d6d6;
  background: #f7f7f7;
}
.seller-avatar,
.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-weight: 700;
  color: #fff;
  user-select: none;
}
.seller-avatar,
.avatar.bot { background: #18a058; }
.avatar.user { background: #3b82f6; }
.chat-title { min-width: 0; flex: 1; }
.chat-title h1 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}
.chat-title p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button {
  border: 1px solid #c9ced6;
  border-radius: 4px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
}
button:hover { background: #f3f4f6; }
#resetBtn {
  height: 34px;
  padding: 0 14px;
}
.messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 18px 8px;
  background: #ededed;
}
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 14px;
}
.message-row.user {
  flex-direction: row-reverse;
}
.bubble {
  position: relative;
  max-width: min(680px, 76%);
  padding: 10px 12px;
  border-radius: 4px;
  line-height: 1.55;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.03);
}
.image-gallery {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.image-gallery:first-child {
  margin-top: 0;
}
.image-gallery img {
  display: block;
  max-width: min(280px, 100%);
  max-height: 260px;
  border-radius: 4px;
  object-fit: contain;
  background: #f3f4f6;
  cursor: zoom-in;
}
.image-gallery img.quantity-compare-image {
  width: min(760px, 100%);
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e5e7eb;
}
.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, .86);
}
.image-preview-modal.open {
  display: flex;
}
.image-preview-modal img {
  max-width: 94vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}
.image-preview-close {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  color: #111827;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.image-preview-title {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 12px;
  color: #e5e7eb;
  text-align: center;
  font-size: 14px;
}
.message-row.bot .bubble {
  background: #fff;
}
.message-row.user .bubble {
  background: #95ec69;
}
.message-row.bot .bubble::before,
.message-row.user .bubble::before {
  content: "";
  position: absolute;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.message-row.bot .bubble::before {
  left: -6px;
  border-right: 6px solid #fff;
}
.message-row.user .bubble::before {
  right: -6px;
  border-left: 6px solid #95ec69;
}
.typing {
  min-width: 56px;
  padding: 11px 13px;
}
.typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: #9ca3af;
  animation: bounce 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; margin-right: 0; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-5px); opacity: 1; }
}
.composer {
  flex: 0 0 auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid #d6d6d6;
  background: #f7f7f7;
}
.tool-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 20px;
  border-radius: 50%;
}
.composer input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d5d8de;
  border-radius: 4px;
  background: #fff;
  font-size: 15px;
  outline: none;
}
.composer input:focus {
  border-color: #8bcf79;
}
.send-btn {
  height: 40px;
  min-width: 72px;
  border-color: #18a058;
  background: #18a058;
  color: #fff;
}
.send-btn:hover { background: #14884c; }
.panel {
  display: none;
}
.panel-section {
  padding: 0 0 16px;
  margin: 0 0 16px;
  border-bottom: 1px solid #e5e7eb;
}
.panel-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}
.status-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  color: #4b5563;
  background: #f9fafb;
}
.status-pill.running {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}
.status-pill.done {
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}
.status-pill.warn {
  border-color: #fcd34d;
  color: #92400e;
  background: #fffbeb;
}
.param-list {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px 10px;
  margin: 0;
  font-size: 13px;
}
dt { color: #6b7280; }
dd { margin: 0; word-break: break-word; }
.run-log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.run-log li {
  position: relative;
  padding: 8px 9px 8px 28px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #f9fafb;
  font-size: 12px;
}
.run-log li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}
.run-log li.input::before { background: #3b82f6; }
.run-log li.memory::before { background: #64748b; }
.run-log li.extract::before { background: #14b8a6; }
.run-log li.model::before { background: #8b5cf6; }
.run-log li.quote::before { background: #f97316; }
.run-log li.talk::before { background: #06b6d4; }
.run-log li.check::before { background: #22c55e; }
.run-log li.output::before { background: #111827; }
.run-log li.done::before { background: #22c55e; }
.run-log li.warn::before { background: #f59e0b; }
.run-log li.input { border-color: #bfdbfe; background: #eff6ff; }
.run-log li.memory { border-color: #cbd5e1; background: #f8fafc; }
.run-log li.extract { border-color: #99f6e4; background: #f0fdfa; }
.run-log li.model { border-color: #ddd6fe; background: #f5f3ff; }
.run-log li.quote { border-color: #fed7aa; background: #fff7ed; }
.run-log li.talk { border-color: #a5f3fc; background: #ecfeff; }
.run-log li.check { border-color: #bbf7d0; background: #f0fdf4; }
.run-log li.output { border-color: #d1d5db; background: #f9fafb; }
.run-log li.warn { border-color: #fde68a; background: #fffbeb; }
.run-log li.muted {
  color: #9ca3af;
}
.run-log strong {
  display: block;
  margin: 0 0 3px;
  font-size: 13px;
  color: #111827;
}
.run-log span {
  display: block;
  color: #6b7280;
  line-height: 1.45;
}
@media (max-width: 980px) {
  .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .wechat { height: 72vh; min-height: 520px; }
  .panel {
    position: static;
    max-height: none;
  }
  .bubble { max-width: 82%; }
}
