:root { color-scheme: light; --line: #e5e7eb; --text: #1f2937; --muted: #7b8494; --primary: #397ff1; --soft: #f0f1f4; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: #f5f6f8;
  color: var(--text);
}

.support-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.support-panel {
  width: min(760px, 100%);
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  box-shadow: 0 0 36px rgba(31, 41, 55, 0.08);
}

.chat-header { height: 64px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; border-bottom: 1px solid var(--line); padding: 0 12px; text-align: center; font-size: 18px; }
.back-button { border: 0; background: transparent; font-size: 42px; line-height: 1; text-align: left; cursor: pointer; color: #111827; padding: 0; }
.close-chat-button { border: 0; background: transparent; font-size: 32px; line-height: 1; cursor: pointer; color: #111827; padding: 0; text-align: right; }
.close-chat-button:disabled { opacity: .45; cursor: not-allowed; }
.service-bar { min-height: 72px; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; background: var(--primary); color: white; }
.service-bar div { display: grid; gap: 4px; }
.service-bar strong { font-size: 16px; }
.service-bar span { font-size: 14px; }
.service-icon { font-size: 26px !important; }

.chat-transcript {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 18px 28px;
  background: #fff;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
}
.chat-message-row { margin-bottom: 18px; display: flex; flex-direction: column; align-items: flex-start; }
.chat-message-row.customer { align-items: flex-end; }
.sender-name { font-size: 11px; color: var(--muted); margin: 0 4px 5px; }

.chat-bubble {
  display: inline-block;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: min(82%, 540px);
  max-height: none !important;
  padding: 11px 14px;
  border-radius: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  position: static !important;
  transform: none !important;
  zoom: 1 !important;
  -webkit-user-select: text;
  user-select: text;
}

.chat-bubble.agent { background: var(--soft); color: #20242c; }

.chat-bubble.customer { background: #76b69e; color: #fff; }
.attachment-image, .attachment-video { display: block; max-width: min(100%, 480px); max-height: 420px; border-radius: 10px; object-fit: contain; background: #111; }
.attachment-link { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; min-width: 180px; }
.attachment-link strong { font-size: 26px; }
.attachment-caption { margin-top: 8px; }
.copy-message { display: block; margin: 7px 0 0 auto; padding: 2px 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 11px; opacity: .72; cursor: pointer; -webkit-user-select: none; user-select: none; }

.chat-form { border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; position: relative; }
.tool-row { display: flex; align-items: center; gap: 12px; color: #697386; }
.tool-button { border: 0; background: transparent; padding: 2px; font-size: 24px; line-height: 1; color: #697386; cursor: pointer; }
.character-count { margin-left: auto; font-size: 13px; color: var(--muted); }
.composer-row { display: grid; grid-template-columns: 1fr 48px; gap: 10px; align-items: end; }

.chat-form textarea { width: 100%; border: 0; outline: 0; resize: none; min-height: 52px; max-height: 130px; padding: 11px 6px 4px; font: inherit; line-height: 1.5; }

.send-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--primary); color: #fff; font-size: 22px; cursor: pointer; }
.send-button:disabled { opacity: .55; cursor: wait; }
.send-state { min-height: 16px; color: #c23b4a; font-size: 12px; }
.chat-form.window-closed { background: #f5f6f8; }
.chat-form.window-closed .tool-row,
.chat-form.window-closed .composer-row,
.chat-form.window-closed .send-state { display: none; }
.closed-banner { padding: 12px 14px; border-radius: 10px; background: #fff0f2; color: #b4233c; font-size: 14px; text-align: center; }
.emoji-panel { position: absolute; left: 14px; bottom: calc(100% - 4px); width: min(360px, calc(100vw - 28px)); padding: 12px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 12px 36px rgba(15, 23, 42, .16); }
.emoji-panel button { border: 0; background: transparent; font-size: 22px; padding: 4px; cursor: pointer; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .support-panel { width: 100%; box-shadow: none; }
  .chat-bubble { max-width: 88%; }
  .chat-header { height: 58px; font-size: 17px; }
}
