:root {
  --cs-bg: #101820;
  --cs-panel: #16232d;
  --cs-ink: #eaf6f4;
  --cs-muted: #8da6a3;
  --cs-line: #29414a;
  --cs-accent: #4fd1c5;
  --cs-accent-ink: #07201d;
  --cs-danger: #ff8f8f;
}

.cs-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--cs-ink);
}

.cs-widget * { box-sizing: border-box; }

.cs-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #3f6f70;
  border-radius: 999px;
  background: linear-gradient(145deg, #193c3d, #0e2429);
  color: var(--cs-ink);
  padding: 11px 17px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.cs-bubble-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cs-accent); box-shadow: 0 0 0 4px rgba(79,209,197,.14); }

.cs-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 24px));
  overflow: hidden;
  border: 1px solid #31525a;
  border-radius: 20px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(79,209,197,.12), transparent 55%),
    linear-gradient(180deg, #13242c, #0d171d);
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.cs-widget.is-open .cs-panel { display: flex; flex-direction: column; }
.cs-widget.is-open .cs-bubble { display: none; }

.cs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--cs-line);
  background: rgba(11, 24, 30, .7);
}
.cs-head strong { display: block; font-size: 14px; }
.cs-sub { display: block; margin-top: 2px; color: var(--cs-muted); font-size: 10px; }
.cs-close {
  width: 30px; height: 30px; border: 1px solid var(--cs-line); border-radius: 9px;
  background: #14262e; color: var(--cs-ink); font-size: 19px; cursor: pointer;
}

.cs-consent { padding: 18px 16px; overflow: auto; }
.cs-consent-text { margin: 0 0 14px; color: #c6dad7; font-size: 12px; line-height: 1.65; }
.cs-check {
  display: flex; align-items: center; gap: 9px;
  margin: 8px 0; padding: 9px 10px;
  border: 1px solid #29414a; border-radius: 10px;
  background: #13232a; color: #d5e8e5; font-size: 12px;
}
.cs-check input { accent-color: var(--cs-accent); width: 15px; height: 15px; }
.cs-primary {
  width: 100%; margin-top: 14px; border: 0; border-radius: 11px;
  background: var(--cs-accent); color: var(--cs-accent-ink);
  padding: 11px 12px; font: inherit; font-weight: 800; cursor: pointer;
}
.cs-primary:disabled { opacity: .55; cursor: wait; }
.cs-error { min-height: 17px; margin: 9px 0 0; color: var(--cs-danger); font-size: 11px; }
.cs-fine { margin: 10px 0 0; color: var(--cs-muted); font-size: 10px; line-height: 1.5; }

.cs-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cs-status {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 15px; border-bottom: 1px solid var(--cs-line);
  color: var(--cs-muted); font-size: 11px;
}
.cs-state { color: #8fe3d9; }
.cs-link { border: 0; background: transparent; color: #9de6dd; font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cs-messages { flex: 1; overflow: auto; padding: 13px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.cs-msg { max-width: 90%; display: flex; flex-direction: column; gap: 3px; }
.cs-msg-visitor { align-self: flex-end; align-items: flex-end; }
.cs-msg-ai, .cs-msg-human { align-self: flex-start; align-items: flex-start; }
.cs-who { color: var(--cs-muted); font-size: 9px; }
.cs-bubble-text {
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6;
  padding: 9px 11px; border-radius: 12px; font-size: 12px;
  background: #172b33; border: 1px solid #29454e;
}
.cs-msg-visitor .cs-bubble-text { background: #1f4a45; border-color: #357a70; color: #f1fffc; }
.cs-msg-human .cs-bubble-text { background: #2a2c45; border-color: #4b4e74; }
.cs-msg.is-pending .cs-bubble-text { opacity: .72; }
.cs-compose {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px 6px; border-top: 1px solid var(--cs-line);
}
.cs-compose textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 92px;
  border: 1px solid #31525a; border-radius: 10px;
  background: #0e1d23; color: var(--cs-ink);
  padding: 9px 10px; font: inherit; font-size: 12px; line-height: 1.45;
}
.cs-compose textarea:focus { outline: 2px solid rgba(79,209,197,.35); border-color: #4fafa5; }
.cs-send {
  border: 0; border-radius: 10px; background: var(--cs-accent); color: var(--cs-accent-ink);
  padding: 10px 12px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.cs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 520px) {
  .cs-widget { right: 10px; bottom: 10px; }
  .cs-panel { width: calc(100vw - 32px); height: min(590px, calc(100vh - 20px)); border-radius: 16px; }
  .cs-consent { padding: 14px 13px; }
}

.cs-widget [hidden] { display: none !important; }

.cs-citations { color: #6f918d; font-size: 9px; line-height: 1.45; }
