* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f3f3f0;
  color: #1c1c1a;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font-family: inherit;
}

.layout {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.chat {
  width: 100%;
  max-width: 720px;
  height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e2dd;
  border-radius: 10px;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #ececE7;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: #1d4d3f;
  color: #ffffff;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
}

.identity-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.presence {
  margin: 2px 0 0;
  font-size: 12px;
  color: #83837a;
}

.presence.online {
  color: #1d4d3f;
}

.new-session {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  color: #1d4d3f;
  background: transparent;
  border: 1px solid #cfd8d3;
  border-radius: 6px;
  cursor: pointer;
}

.new-session:hover {
  background: #f2f6f4;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 10px;
}

.msg {
  display: flex;
  margin-bottom: 14px;
}

.msg.right {
  justify-content: flex-end;
}

.bubble-wrap {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}

.msg.right .bubble-wrap {
  align-items: flex-end;
}

.bubble {
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.left .bubble {
  background: #f4f4f1;
  color: #1c1c1a;
}

.msg.right .bubble {
  background: #1d4d3f;
  color: #ffffff;
}

.meta {
  margin-top: 4px;
  font-size: 11px;
  color: #a2a29a;
}

.system {
  margin: 0 0 14px;
  text-align: center;
  font-size: 12px;
  color: #92928a;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid #ececE7;
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #1c1c1a;
  background: #fbfbf9;
  border: 1px solid #dedeD8;
  border-radius: 8px;
  resize: none;
  outline: none;
}

.composer textarea:focus {
  border-color: #1d4d3f;
  background: #ffffff;
}

.composer textarea:disabled {
  background: #f6f6f3;
  color: #9c9c94;
}

.attach {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #5f5f58;
  background: #fbfbf9;
  border: 1px solid #dedeD8;
  border-radius: 8px;
  cursor: pointer;
}

.attach:hover:not(:disabled) {
  color: #1d4d3f;
  border-color: #1d4d3f;
}

.attach:disabled {
  color: #c4c4bc;
  cursor: not-allowed;
}

.bubble.image {
  padding: 4px;
  background: transparent;
}

.msg.left .bubble.image {
  background: transparent;
}

.msg.right .bubble.image {
  background: transparent;
}

.bubble-image {
  display: block;
  max-width: 240px;
  max-height: 200px;
  border-radius: 6px;
  cursor: zoom-in;
}

.send {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: #1d4d3f;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.send:disabled {
  background: #d8d8d2;
  cursor: not-allowed;
}

/* widget 内嵌模式 */
body.embed {
  background: #ffffff;
}

body.embed .layout {
  padding: 0;
}

body.embed .chat {
  max-width: none;
  height: 100%;
  border: 0;
  border-radius: 0;
}

body.embed .chat-head {
  padding: 12px 14px;
}

@media (max-width: 560px) {
  .layout {
    padding: 0;
  }

  .chat {
    height: 100%;
    max-width: none;
    border: 0;
    border-radius: 0;
  }

  .messages {
    padding: 16px 14px 8px;
  }
}

/* 图片预览弹层 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(16, 18, 17, 0.82);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 94%;
  max-height: 88%;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

body.lightbox-open {
  overflow: hidden;
}
