#oc-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
}

#oc-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  background: #4f46e5;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

#oc-chat-toggle:hover {
  transform: scale(1.05);
  background: #4338ca;
}

#oc-chat-toggle svg {
  width: 26px;
  height: 26px;
}

#oc-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  display: none;
  flex-direction: column;
  background: #fff;
  color: #111827;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

#oc-chat-panel.open {
  display: flex;
}

.oc-chat-header {
  padding: 14px 16px;
  background: #4f46e5;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.oc-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oc-chat-header button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.oc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9fafb;
}

.oc-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.45;
}

.oc-msg.user {
  align-self: flex-end;
  background: #4f46e5;
  color: #fff;
  border-bottom-right-radius: 3px;
}

.oc-msg.bot {
  align-self: flex-start;
  background: #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 3px;
  white-space: normal;
}

.oc-msg.bot > :first-child {
  margin-top: 0;
}

.oc-msg.bot > :last-child {
  margin-bottom: 0;
}

.oc-msg.bot p {
  margin: 0 0 8px;
}

.oc-msg.bot ul,
.oc-msg.bot ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.oc-msg.bot li {
  margin: 2px 0;
}

.oc-msg.bot li > p {
  margin: 0;
}

.oc-msg.bot h1,
.oc-msg.bot h2,
.oc-msg.bot h3,
.oc-msg.bot h4 {
  margin: 8px 0 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.oc-msg.bot a {
  color: #4f46e5;
  text-decoration: underline;
}

.oc-msg.bot code {
  background: rgba(17, 24, 39, 0.09);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.oc-msg.bot pre {
  background: #111827;
  color: #f9fafb;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 8px;
}

.oc-msg.bot pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 12.5px;
}

.oc-msg.bot blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 3px solid #9ca3af;
  color: #4b5563;
}

.oc-msg.bot table {
  border-collapse: collapse;
  margin: 0 0 8px;
  font-size: 13px;
}

.oc-msg.bot th,
.oc-msg.bot td {
  border: 1px solid #9ca3af;
  padding: 3px 6px;
  text-align: left;
}

.oc-msg.bot hr {
  border: none;
  border-top: 1px solid #9ca3af;
  margin: 8px 0;
}

.oc-msg.error {
  align-self: flex-start;
  background: #fee2e2;
  color: #991b1b;
}

.oc-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.oc-chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  max-height: 96px;
  outline: none;
}

.oc-chat-input textarea:focus {
  border-color: #4f46e5;
}

.oc-chat-input button {
  border: none;
  background: #4f46e5;
  color: #fff;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
}

.oc-chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dark mode */
html.dark #oc-chat-panel {
  background: #1f2937;
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.1);
}
html.dark .oc-chat-messages {
  background: #111827;
}
html.dark .oc-msg.bot {
  background: #374151;
  color: #f3f4f6;
}
html.dark .oc-chat-input {
  background: #1f2937;
  border-top-color: #374151;
}
html.dark .oc-chat-input textarea {
  background: #111827;
  color: #f3f4f6;
  border-color: #4b5563;
}
