/* messenger-style support chat (chat.js) */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--bg);
}
.chat-scroll {
  flex: 1;
  min-height: 260px;
  max-height: min(62vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chat-list { display: flex; flex-direction: column; }
.chat-empty { margin: 40px auto; color: var(--muted); font-size: 14px; text-align: center; }
.chat-day {
  align-self: center;
  margin: 14px 0 10px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .02em;
}
.chat-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 3px; max-width: 100%; }
.chat-row.first { margin-top: 12px; }
.chat-row.mine { justify-content: flex-end; }
.chat-row.pending { opacity: .6; }

.chat-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  color: var(--soft);
  font-size: 12px;
  font-weight: 600;
  align-self: flex-start;
}
.chat-avatar img { width: 14px; height: 14px; }
.chat-avatar.spacer { visibility: hidden; height: 1px; }

.chat-bubble {
  position: relative;
  max-width: min(78%, 560px);
  padding: 9px 13px 7px;
  border-radius: 16px;
  line-height: 1.42;
}
.chat-row.theirs .chat-bubble {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text);
}
.chat-row.mine .chat-bubble {
  background: var(--text);
  color: var(--black);
}
.chat-row.theirs.first .chat-bubble { border-top-left-radius: 5px; }
.chat-row.mine.first .chat-bubble { border-top-right-radius: 5px; }
.chat-name { display: block; margin-bottom: 2px; color: var(--soft); font-size: 12px; font-weight: 600; }
.chat-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.chat-time {
  display: block;
  margin-top: 2px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}
.chat-row.mine .chat-time { color: #5c5c63; }

.chat-notice {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-input {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}
.chat-input:focus { outline: none; border-color: var(--muted); }
.chat-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  color: var(--black);
  cursor: pointer;
  transition: opacity .15s ease, transform .15s ease;
}
.chat-send:disabled { opacity: .3; cursor: default; }
.chat-send:not(:disabled):hover { transform: translateY(-1px); }
.chat-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat-hint { margin: 0; padding: 0 18px 10px; background: var(--surface); color: #6d6d73; font-size: 11px; }
.chat-hint:empty { display: none; }

@media (max-width: 560px) {
  .chat-scroll { padding: 14px 10px 6px; max-height: 64vh; }
  .chat-bubble { max-width: 86%; }
  .chat-composer { padding: 10px; }
}
