:root {
  --chatter-accent: #2f8a4f;
  --chatter-accent-dark: #1f6a3b;
  --chatter-bg: #ffffff;
  --chatter-fg: #1a1a1a;
  --chatter-muted: #6b7280;
  --chatter-bubble-user: #e8f5ec;
  --chatter-bubble-bot: #f3f4f6;
  --chatter-border: #e5e7eb;
  --chatter-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.chatter-root,
.chatter-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

.chatter-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chatter-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--chatter-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 2147483646;
  transition: transform 0.15s ease;
}
.chatter-launcher:hover {
  transform: scale(1.05);
  background: var(--chatter-accent-dark);
}
.chatter-launcher[aria-expanded="true"] {
  display: none;
}

.chatter-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 48px);
  background: var(--chatter-bg);
  color: var(--chatter-fg);
  border-radius: 14px;
  box-shadow: var(--chatter-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483647;
}
.chatter-panel[data-open="true"] {
  display: flex;
}

.chatter-header {
  background: var(--chatter-accent);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chatter-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--chatter-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}
.chatter-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
}
.chatter-title strong {
  font-size: 15px;
}
.chatter-status {
  font-size: 12px;
  opacity: 0.9;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chatter-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9be4ae;
  display: inline-block;
}
.chatter-status[data-configured="false"]::before {
  background: #f4b860;
}
.chatter-iconbtn {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.chatter-iconbtn:hover {
  background: rgba(255, 255, 255, 0.15);
}
.chatter-close {
  font-size: 20px;
}

.chatter-feedback {
  background: var(--chatter-accent-dark);
  color: #fff;
  padding: 8px 14px;
  font-size: 12px;
}
.chatter-feedback a {
  color: #fff;
  text-decoration: underline;
}

.chatter-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chatter-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
}
.chatter-body[data-hidden="true"] {
  display: none;
}

.chatter-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chatter-msg.bot {
  background: var(--chatter-bubble-bot);
  color: var(--chatter-fg);
  border-top-left-radius: 4px;
}
.chatter-msg.user {
  background: var(--chatter-bubble-user);
  color: var(--chatter-fg);
  margin-left: auto;
  border-top-right-radius: 4px;
}
.chatter-msg.system {
  background: transparent;
  color: var(--chatter-muted);
  font-size: 12px;
  text-align: center;
  margin: 8px auto;
  max-width: 100%;
}
.chatter-msg a {
  color: var(--chatter-accent-dark);
}

.chatter-msg.chatter-rest {
  max-width: 100%;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
}
.chatter-msg.chatter-rest-collapsed {
  background: transparent;
  border: 1px solid var(--chatter-border);
  color: var(--chatter-muted);
  font-size: 11.5px;
}
.chatter-msg.chatter-rest-collapsed[open] {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #0f172a;
}
.chatter-rest-status {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all;
  background: #1e293b;
}
.chatter-rest-collapsed > .chatter-rest-status {
  background: transparent;
  padding: 6px 10px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chatter-rest-collapsed > .chatter-rest-status::-webkit-details-marker { display: none; }
.chatter-rest-collapsed > .chatter-rest-status::before {
  content: "›";
  font-size: 14px;
  transition: transform 0.15s;
  color: var(--chatter-muted);
}
.chatter-rest-collapsed[open] > .chatter-rest-status {
  background: #1e293b;
  font-weight: 600;
}
.chatter-rest-collapsed[open] > .chatter-rest-status::before {
  transform: rotate(90deg);
}
.chatter-rest-status.ok { color: #86efac; }
.chatter-rest-status.err { color: #fda4af; }
.chatter-rest-collapsed:not([open]) > .chatter-rest-status.ok { color: #16a34a; }
.chatter-rest-collapsed:not([open]) > .chatter-rest-status.err { color: #dc2626; }
.chatter-rest-body {
  margin: 0;
  padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.4;
  color: #e2e8f0;
  background: #0f172a;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}
.chatter-rest-collapsed:not([open]) > .chatter-rest-body { display: none; }

.chatter-topics {
  padding: 0 14px 10px;
  background: #fafafa;
  border-top: 1px dashed var(--chatter-border);
}
.chatter-topics[data-hidden="true"] {
  display: none !important;
}

.chatter-settings {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
}
.chatter-settings[data-open="true"] {
  display: block;
}
.chatter-settings-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--chatter-fg);
  margin-bottom: 4px;
}
.chatter-settings-hint {
  font-size: 12px;
  color: var(--chatter-muted);
  margin-bottom: 16px;
}
.chatter-field {
  display: block;
  margin-bottom: 12px;
}
.chatter-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--chatter-fg);
  margin-bottom: 4px;
}
.chatter-field input {
  width: 100%;
  border: 1px solid var(--chatter-border);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--chatter-fg);
  background: #fff;
}
.chatter-field input:focus {
  outline: none;
  border-color: var(--chatter-accent);
  box-shadow: 0 0 0 3px rgba(47, 138, 79, 0.15);
}
.chatter-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.chatter-btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
}
.chatter-btn.primary {
  background: var(--chatter-accent);
  color: #fff;
  border-color: var(--chatter-accent);
}
.chatter-btn.primary:hover {
  background: var(--chatter-accent-dark);
  border-color: var(--chatter-accent-dark);
}
.chatter-btn.ghost {
  background: #fff;
  color: var(--chatter-fg);
  border-color: var(--chatter-border);
}
.chatter-btn.ghost:hover {
  background: #f3f4f6;
}
.chatter-topics-title {
  font-size: 13px;
  color: var(--chatter-muted);
  margin: 10px 0 8px;
}
.chatter-topic {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--chatter-border);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--chatter-fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chatter-topic:hover {
  border-color: var(--chatter-accent);
  color: var(--chatter-accent-dark);
}
.chatter-topic::after {
  content: "›";
  color: var(--chatter-muted);
  font-size: 18px;
}

.chatter-input {
  border-top: 1px solid var(--chatter-border);
  background: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chatter-input input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  padding: 8px 4px;
  background: transparent;
  color: var(--chatter-fg);
}
.chatter-send {
  background: var(--chatter-accent);
  color: #fff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatter-send:hover {
  background: var(--chatter-accent-dark);
}
.chatter-send:disabled {
  background: #b8c7bf;
  cursor: not-allowed;
}

.chatter-typing {
  display: inline-flex;
  gap: 3px;
  padding: 10px 12px;
}
.chatter-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chatter-muted);
  animation: chatter-bounce 1.2s infinite ease-in-out;
}
.chatter-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.chatter-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chatter-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}
