:root {
  --text: #17181a;
  --muted: #6b7076;
  --line: #dfe4e8;
  --surface: #ffffff;
  --soft: #f3f6f8;
  --accent: #0b6e4f;
  --accent-dark: #075c43;
  --chat-max: 680px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 100%;
  overflow-x: clip;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: #e9edf1;
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.chat-app {
  display: flex;
  flex-direction: column;
  width: min(100%, var(--chat-max));
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  border-inline: 1px solid var(--line);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-avatar {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
}

.chat-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chat-avatar rect {
  fill: #e7f2ec;
  stroke: #bcdccd;
}

.chat-avatar circle {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

.chat-avatar text {
  fill: var(--accent);
  font-family: "SF Pro Display", "PingFang SC", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.chat-heading h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1f9d6d;
}

.chat-window {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 32px;
  background: var(--soft);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.message.ai {
  justify-content: flex-start;
}

.bubble {
  max-width: min(86%, 460px);
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.ai .bubble {
  background: var(--surface);
  border: 1px solid #e3e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(23, 24, 26, 0.04);
}

.contact-bubble p {
  margin: 4px 0;
}

.contact-bubble a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.contact-bubble a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.wechat-bubble {
  max-width: 260px;
  text-align: center;
}

.wechat-bubble img {
  display: block;
  width: 100%;
  max-width: 220px;
  margin-inline: auto;
  border-radius: 8px;
}

.qr-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chat-controls {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

button {
  font: inherit;
}

.quick-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.start-chat-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.start-chat-button:hover {
  background: var(--accent-dark);
}

.start-chat-button:disabled {
  border-color: #c6d2cc;
  background: #c6d2cc;
  color: #ffffff;
  cursor: default;
}

.add-friend-button {
  border: 1px solid #bcdccd;
  background: #e7f2ec;
  color: var(--accent);
}

.add-friend-button:hover {
  background: #dcefe5;
}

.add-friend-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.compose {
  display: flex;
  gap: 10px;
}

.compose input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid #ccd3d9;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.compose input::placeholder {
  color: #9aa1a8;
}

.compose button {
  flex: 0 0 auto;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.compose button:hover {
  background: var(--accent-dark);
}

.site-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .chat-header,
  .chat-controls,
  .site-footer {
    padding-inline: 16px;
  }

  .chat-window {
    padding-inline: 14px;
  }

  .bubble {
    max-width: 90%;
  }

  .compose button {
    padding-inline: 14px;
  }
}
