:root {
  color-scheme: light;
  --chat-bg: #f6f7fb;
  --chat-panel: #ffffff;
  --chat-ink: #141824;
  --chat-muted: #697184;
  --chat-line: #dfe4ee;
  --chat-primary: #d72d4d;
  --chat-primary-dark: #a81934;
  --chat-accent: #136f63;
  --chat-soft: #f1f3f8;
  --chat-shadow: 0 24px 70px rgba(25, 32, 52, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  height: 100%;
}

body.chat-page {
  margin: 0;
  min-height: 100dvh;
  color: var(--chat-ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(215, 45, 77, 0.18), transparent 32%),
    radial-gradient(circle at 90% 8%, rgba(19, 111, 99, 0.16), transparent 30%),
    linear-gradient(135deg, #fbf7f0 0%, #f6f7fb 45%, #eef5f4 100%);
}

body.support-page {
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.chat-shell {
  display: grid;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
}

.visitor-panel {
  display: grid;
  width: min(100%, 980px);
  gap: 22px;
}

.chat-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-brand a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  color: #ffffff;
  background: #111827;
  text-decoration: none;
  font-weight: 800;
}

.chat-brand span {
  color: var(--chat-muted);
  font-size: 14px;
}

.chat-intro {
  max-width: 720px;
}

.chat-intro p {
  margin: 0 0 10px;
  color: var(--chat-primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.chat-intro h1 {
  margin: 0;
  color: #111827;
  font-size: clamp(32px, 6vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.chat-intro span {
  display: block;
  margin-top: 14px;
  color: var(--chat-muted);
  font-size: 17px;
  line-height: 1.8;
}

.chat-card {
  display: grid;
  width: 100%;
  height: min(720px, calc(100vh - 48px));
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--chat-shadow);
  grid-template-rows: auto auto 1fr auto;
}

.chat-card-head {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chat-line);
  background: rgba(255, 255, 255, 0.84);
}

.chat-card-head > div {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d1d5db;
  box-shadow: 0 0 0 4px rgba(209, 213, 219, 0.28);
}

.is-connected .status-dot {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16);
}

.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--chat-primary-dark);
  background: #fff0f3;
  font-weight: 700;
}

.profile-form {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chat-line);
  background: #fbfcff;
}

.profile-form label,
.support-login label {
  color: var(--chat-muted);
  font-size: 13px;
  font-weight: 700;
}

.profile-form div,
.support-login div {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

.profile-form input,
.support-login input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--chat-ink);
  background: #ffffff;
  outline: none;
}

.profile-form input:focus,
.support-login input:focus,
.composer textarea:focus {
  border-color: rgba(215, 45, 77, 0.62);
  box-shadow: 0 0 0 3px rgba(215, 45, 77, 0.12);
}

.profile-form button,
.support-login button,
.composer button {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--chat-primary);
  font-weight: 800;
  white-space: nowrap;
}

.message-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.76)),
    repeating-linear-gradient(135deg, #f6f7fb 0 16px, #ffffff 16px 32px);
  scrollbar-width: thin;
}

.message {
  display: grid;
  max-width: min(82%, 620px);
  gap: 5px;
}

.message.is-me {
  align-self: flex-end;
}

.message.is-system {
  max-width: 100%;
  align-self: center;
}

.message-meta {
  color: var(--chat-muted);
  font-size: 12px;
}

.message-bubble {
  border-radius: 8px;
  padding: 11px 13px;
  color: #111827;
  background: #ffffff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message.is-me .message-bubble {
  color: #ffffff;
  background: var(--chat-primary);
  border-color: var(--chat-primary);
}

.message.is-system .message-bubble {
  color: var(--chat-muted);
  background: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  text-align: center;
}

.composer {
  display: grid;
  align-items: end;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
  border-top: 1px solid var(--chat-line);
  background: #ffffff;
}

.composer textarea {
  width: 100%;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  resize: none;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.55;
  outline: none;
  overflow-y: auto;
  scrollbar-width: none;
}

.composer textarea::-webkit-scrollbar {
  display: none;
}

.composer button {
  display: inline-flex;
  width: 78px;
  min-width: 78px;
  height: 52px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  box-shadow: 0 10px 20px rgba(215, 45, 77, 0.22);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.composer button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(215, 45, 77, 0.28);
}

.composer button:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(215, 45, 77, 0.22);
}

.support-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(300px, 360px) 1fr;
  background: #f6f7fb;
}

.support-sidebar {
  display: grid;
  min-height: 100dvh;
  align-content: start;
  gap: 16px;
  padding: 18px;
  border-right: 1px solid var(--chat-line);
  background: #ffffff;
}

.support-login {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: #fbfcff;
}

.support-login div {
  grid-template-columns: 1fr;
}

.session-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.session-toolbar button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--chat-accent);
  background: #e9f6f3;
  font-weight: 800;
}

.session-list {
  display: grid;
  gap: 10px;
}

.session-item {
  display: grid;
  width: 100%;
  gap: 5px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 12px;
  color: inherit;
  background: #ffffff;
  text-align: left;
}

.session-item.is-active {
  border-color: rgba(215, 45, 77, 0.5);
  background: #fff5f6;
}

.session-item strong {
  font-size: 15px;
}

.session-item span {
  color: var(--chat-muted);
  font-size: 12px;
}

.session-item b {
  justify-self: start;
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #ffffff;
  background: var(--chat-primary);
  font-size: 12px;
}

.support-chat {
  display: grid;
  min-width: 0;
  padding: 24px;
}

.support-empty {
  display: grid;
  min-height: calc(100vh - 48px);
  place-items: center;
  color: var(--chat-muted);
  border: 1px dashed #c8cfdd;
  border-radius: 8px;
  background: #ffffff;
}

.support-chat-card {
  height: calc(100vh - 48px);
  min-height: calc(100vh - 48px);
}

.support-chat-card .message-list {
  min-height: 0;
}

.is-hidden {
  display: none;
}

@media (max-width: 760px) {
  body.chat-visitor-page {
    overflow: hidden;
  }

  .chat-shell,
  .support-chat {
    padding: 0;
  }

  .chat-shell {
    display: block;
    min-height: 100dvh;
  }

  .visitor-panel {
    width: 100%;
    height: 100dvh;
    gap: 0;
  }

  .visitor-panel > .chat-brand,
  .visitor-panel > .chat-intro {
    display: none;
  }

  .chat-intro h1 {
    font-size: 34px;
  }

  .chat-card {
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .chat-card-head {
    min-height: 56px;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  }

  .ghost-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .profile-form {
    padding: 12px 14px;
  }

  .profile-form div {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .profile-form input,
  .profile-form button {
    min-height: 42px;
    font-size: 14px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 64px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }

  .composer textarea,
  .composer button {
    height: 46px;
    min-height: 46px;
    max-height: 46px;
  }

  .message {
    max-width: 92%;
  }

  .composer button {
    width: 64px;
    min-width: 64px;
  }

  body.support-page {
    min-height: 100dvh;
    overflow: hidden;
  }

  .support-shell {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .support-sidebar {
    min-height: auto;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--chat-line);
  }

  .support-sidebar .chat-brand a {
    min-height: 38px;
    padding: 0 12px;
  }

  .support-login {
    padding: 12px;
  }

  .support-login input,
  .support-login button {
    min-height: 42px;
  }

  .session-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 4px 0;
    background: #ffffff;
  }

  .session-list {
    max-height: 150px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .session-item {
    padding: 10px;
  }

  .support-chat {
    display: grid;
    min-height: 0;
    overflow: hidden;
  }

  .support-empty,
  .support-chat-card {
    height: 100%;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .support-chat-card {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .support-chat-card .chat-card-head {
    min-height: 52px;
    padding: 10px 12px;
  }

  .support-chat-card .message-list {
    padding: 12px;
  }

  .support-chat-card .composer {
    padding: 10px 10px calc(86px + env(safe-area-inset-bottom));
  }

  .support-empty {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}
