:root {
  --lance-chat-bg: #0f1115;
  --lance-chat-panel: #141922;
  --lance-chat-panel-2: #1b2330;
  --lance-chat-text: #f5f7fb;
  --lance-chat-muted: #9aa4b2;
  --lance-chat-line: rgba(255,255,255,0.08);
  --lance-chat-amber: #f59e0b;
  --lance-chat-amber-soft: rgba(245, 158, 11, 0.16);
  --lance-chat-user: #233147;
}

.lance-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.lance-chat-toggle {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #111;
  box-shadow: 0 12px 34px rgba(0,0,0,0.35);
  font-size: 30px;
  cursor: pointer;
}

.lance-chat-panel {
  width: min(380px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 110px));
  background: linear-gradient(180deg, var(--lance-chat-panel), var(--lance-chat-bg));
  border: 1px solid var(--lance-chat-line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  overflow: hidden;
  display: none;
}

.lance-chat-root.open .lance-chat-panel {
  display: flex;
  flex-direction: column;
}

.lance-chat-root.open .lance-chat-toggle {
  display: none;
}

.lance-chat-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--lance-chat-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255,255,255,0.02);
}

.lance-chat-title {
  color: var(--lance-chat-text);
  font-size: 15px;
  font-weight: 800;
}

.lance-chat-subtitle {
  color: var(--lance-chat-muted);
  font-size: 12px;
  margin-top: 2px;
}

.lance-chat-close {
  background: transparent;
  border: none;
  color: var(--lance-chat-muted);
  font-size: 22px;
  cursor: pointer;
}

.lance-chat-stage {
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 700;
  color: var(--lance-chat-amber);
  border-bottom: 1px solid var(--lance-chat-line);
  background: var(--lance-chat-amber-soft);
}

.lance-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lance-chat-message {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-wrap;
}

.lance-chat-message.bot {
  align-self: flex-start;
  background: var(--lance-chat-panel-2);
  color: var(--lance-chat-text);
  border: 1px solid var(--lance-chat-line);
}

.lance-chat-message.user {
  align-self: flex-end;
  background: var(--lance-chat-user);
  color: var(--lance-chat-text);
}

.lance-chat-meta {
  color: var(--lance-chat-amber);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lance-chat-card {
  align-self: stretch;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 14px;
  padding: 14px;
}

.lance-chat-card-title {
  color: var(--lance-chat-text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.lance-chat-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lance-chat-card-row {
  color: var(--lance-chat-text);
  font-size: 13px;
  line-height: 1.45;
}

.lance-chat-footer {
  border-top: 1px solid var(--lance-chat-line);
  padding: 14px;
  background: rgba(255,255,255,0.02);
}

.lance-chat-form {
  display: flex;
  gap: 10px;
}

.lance-chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 110px;
  resize: none;
  border-radius: 12px;
  border: 1px solid var(--lance-chat-line);
  background: #0c1118;
  color: var(--lance-chat-text);
  padding: 11px 12px;
  font: inherit;
}

.lance-chat-input::placeholder { color: #738194; }

.lance-chat-send {
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #111;
  font-weight: 800;
  cursor: pointer;
}

.lance-chat-note {
  color: var(--lance-chat-muted);
  font-size: 11px;
  margin-top: 8px;
}

.lance-chat-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.lance-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lance-chat-amber);
  opacity: 0.45;
  animation: lance-chat-bounce 1.2s infinite ease-in-out;
}
.lance-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.lance-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes lance-chat-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

@media (max-width: 640px) {
  .lance-chat-root { right: 12px; bottom: 12px; }
  .lance-chat-panel { width: min(100vw - 12px, 390px); height: min(76vh, 620px); }
}
