* { box-sizing: border-box; }
body, h1, p { margin: 0; }
[hidden] { display: none !important; }

body {
  color: var(--art-gray-900);
  background: var(--default-bg-color);
  font: 14px/1.55 var(--art-font);
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
button:focus-visible { outline: 2px solid var(--main-color); outline-offset: 2px; }

.layout { height: 100vh; height: 100dvh; max-width: 990px; margin: auto; padding: 20px; }
.chat-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--default-box-color);
  border: 1px solid var(--art-card-border);
  border-radius: var(--art-card-radius);
  overflow: hidden;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 68px;
  padding: 11px 21px;
  border-bottom: 1px solid var(--art-card-border);
}
.chat-heading { flex: 1; min-width: 0; }
.chat-heading h1 { font-size: 16px; line-height: 1.3; font-weight: 650; }
.order-context { display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: 3px; color: var(--art-gray-700); font-size: 12px; }
.order-context > span, .copy-order { flex: none; }
.order-context strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; user-select: text; }
.copy-order { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 6px; border: 0; border-radius: 5px; color: var(--art-primary-dark); background: var(--art-primary-soft); }
.copy-order:hover { background: #e1eaff; }
.copy-order svg { width: 14px; height: 14px; }
.status { max-width: 55%; color: var(--art-gray-700); font-size: 12px; text-align: right; }

.avatar {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 9px;
  flex: none;
  background: var(--art-support-bg);
  color: var(--art-support-color);
}
.avatar::after { content: ""; width: 19px; height: 19px; background: currentColor; mask: var(--avatar-icon) center / contain no-repeat; }
.avatar-support { --avatar-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13v-1a8 8 0 0 1 16 0v3a5 5 0 0 1-5 5h-2'/%3E%3Crect x='4' y='11' width='4' height='6' rx='2'/%3E%3Crect x='16' y='11' width='4' height='6' rx='2'/%3E%3C/svg%3E"); }
.avatar-visitor {
  background: var(--art-visitor-bg);
  color: var(--art-visitor-color);
  --avatar-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='3.3'/%3E%3Cpath d='M5 20v-1a7 7 0 0 1 14 0v1'/%3E%3C/svg%3E");
}
.chat-header .avatar { width: 39px; height: 39px; }
.chat-header .avatar::after { width: 23px; height: 23px; }
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 20px clamp(12px, 3vw, 30px);
  background: var(--default-bg-color);
  overflow-anchor: none;
}
.message { display: flex; align-items: flex-start; gap: 8px; max-width: min(87%, 650px); align-self: flex-start; }
.message-body {
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--art-card-border);
  border-radius: var(--art-radius);
  background: var(--default-box-color);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.user .message-body { background: var(--art-primary-soft); border-color: #dce5ff; }
.message.human .message-body { background: #eef8f4; border-color: #dfeee7; }
.message.system { align-self: center; max-width: 94%; }
.message.system .message-body { text-align: center; background: var(--art-gray-200); border: 0; padding: 5px 10px; color: var(--art-gray-700); font-size: 12px; }
.message-sender { display: block; margin-bottom: 3px; color: var(--art-gray-700); font-size: 11px; font-weight: 650; }
.message img { display: block; width: auto; max-width: min(100%, 270px); max-height: 280px; object-fit: contain; border-radius: 6px; }
.message img.guide-image { max-width: 100%; }
.message img + p { margin-top: 5px; }
.message-quote {
  margin: 0 0 6px;
  padding: 4px 8px;
  border-inline-start: 1px solid var(--art-card-border);
  background: var(--art-gray-200);
  border-radius: 3px;
  color: var(--art-gray-700);
  font-size: 12px;
}
.message-quote strong { display: block; }
.message-quote span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.message audio { display: block; width: min(270px, 62vw); max-width: 100%; height: 40px; }
.message video {
  display: block;
  width: min(420px, 65vw);
  max-width: 100%;
  max-height: min(320px, 50vh);
  border-radius: 6px;
  background: #171a20;
}
.outbound-message .message-body { border-style: dashed; }
.send-error { display: block; margin-top: 3px; color: #a93440; font-size: 12px; }
.typing-message .message-body { display: flex; align-items: center; gap: 7px; color: var(--art-gray-700); font-size: 12px; }

.quick-replies-container { border-top: 1px solid var(--art-card-border); padding: 9px 16px 0; }
.quick-replies { display: flex; gap: 6px; overflow-x: auto; padding: 2px 1px 6px; scrollbar-width: thin; }
.quick-reply-btn { white-space: nowrap; padding: 5px 10px; border: 1px solid var(--art-card-border); border-radius: var(--art-radius); color: var(--art-gray-700); background: #fff; font-size: 12px; min-height: 32px; }
.quick-reply-btn:hover:not(:disabled) { background: var(--art-primary-soft); border-color: #dce5ff; color: var(--art-primary-dark); }
.quick-reply-btn:active:not(:disabled) { transform: translateY(1px); }
.chat-input { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: end; gap: 9px; padding: 7px 16px max(14px, env(safe-area-inset-bottom)); }
.chat-input textarea { padding: 9px 11px; border: 1px solid var(--art-card-border); border-radius: var(--art-radius); color: inherit; background: white; outline: none; }
.chat-input textarea { min-height: 42px; max-height: 140px; resize: none; }
.chat-input textarea:focus { border-color: var(--main-color); box-shadow: 0 0 0 2px var(--art-primary-soft); }
.chat-input button { height: 42px; border: 1px solid var(--main-color); border-radius: var(--art-radius); background: var(--main-color); color: white; padding: 0 17px; }
.chat-input button:hover:not(:disabled) { background: var(--art-primary-dark); }
.chat-input .attach-button { padding: 0; display: grid; place-items: center; border-color: var(--art-card-border); background: #fff; color: var(--art-gray-700); }
.chat-input .attach-button:hover:not(:disabled) { background: var(--art-primary-soft); color: var(--art-primary-dark); }
.attach-button svg { width: 20px; height: 20px; }
.attachment-picker { position: relative; }
.attachment-picker > .attach-button { width: 42px; }
.attachment-options {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 8px);
  z-index: 2;
  width: max-content;
  min-width: 126px;
  padding: 4px;
  border: 1px solid var(--art-card-border);
  border-radius: var(--art-radius);
  background: #fff;
  box-shadow: 0 5px 18px rgb(27 41 66 / 12%);
}
.chat-input .attachment-options button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--art-gray-700);
  text-align: start;
}
.chat-input .attachment-options button:hover,
.chat-input .attachment-options button:focus-visible { background: var(--art-primary-soft); color: var(--art-primary-dark); }
.image-selection { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 16px; padding: 5px 9px; border-radius: var(--art-radius); background: var(--art-primary-soft); color: var(--art-gray-700); font-size: 12px; }
.image-selection span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-selection button { flex: none; min-width: 28px; min-height: 28px; color: inherit; background: none; border: 0; }

@media (max-width: 620px) {
  .layout { padding: 0; }
  .chat-shell { border: 0; border-radius: 0; }
  .chat-header { min-height: 62px; padding-inline: 12px; }
  .chat-messages { padding: 14px 10px; gap: 11px; }
  .message { max-width: 92%; }
  .message .avatar { width: 28px; height: 28px; }
  .message .avatar::after { width: 16px; height: 16px; }
  .chat-input, .quick-replies-container { padding-inline: 10px; }
  .chat-input textarea { font-size: 16px; }
}

