.chatbot-toggle {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font: 700 1rem/1 var(--font-body);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
.chatbot-toggle:hover { background: var(--color-primary-hover); }
.chatbot-toggle svg { width: 1.3rem; height: 1.3rem; flex: none; }

.chatbot-panel {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--space-4) + 4rem);
  z-index: 61;
  display: flex;
  flex-direction: column;
  width: min(24rem, calc(100vw - 2 * var(--space-4)));
  height: min(34rem, calc(100dvh - 7rem));
  border: 1px solid oklch(from var(--color-text) l c h / 0.12);
  border-radius: 1.25rem;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.chatbot-panel[hidden] { display: none; }

.chatbot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.chatbot-head strong { display: block; font: 700 1.05rem/1.2 var(--font-display); }
.chatbot-head span { font-size: 0.82rem; opacity: 0.85; }
.chatbot-close {
  width: 2.25rem; height: 2.25rem; flex: none;
  border: 0; border-radius: var(--radius-full);
  background: oklch(1 0 0 / 0.14); color: inherit;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}

.chatbot-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  background: var(--color-bg);
}
.chatbot-msg {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.97rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chatbot-msg.bot { align-self: flex-start; background: var(--color-surface); border: 1px solid oklch(from var(--color-text) l c h / 0.1); border-bottom-left-radius: 0.3rem; }
.chatbot-msg.user { align-self: flex-end; background: var(--color-primary); color: var(--color-text-inverse); border-bottom-right-radius: 0.3rem; }
.chatbot-msg.typing { color: var(--color-text-muted); font-style: normal; }
.chatbot-msg a { color: inherit; text-decoration: underline; }

.chatbot-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid oklch(from var(--color-text) l c h / 0.1);
  background: var(--color-surface);
}
.chatbot-form textarea {
  flex: 1;
  min-height: 2.75rem;
  max-height: 7rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid oklch(from var(--color-text) l c h / 0.2);
  border-radius: 0.8rem;
  background: var(--color-bg);
  color: var(--color-text);
  font: 400 1rem/1.35 var(--font-body);
  resize: none;
}
.chatbot-form textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.chatbot-form button {
  flex: none;
  padding: 0 1rem;
  border: 0;
  border-radius: 0.8rem;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font: 700 0.95rem/1 var(--font-body);
  cursor: pointer;
}
.chatbot-form button:disabled { opacity: 0.55; cursor: default; }
.chatbot-note { padding: 0 0.9rem 0.6rem; background: var(--color-surface); font-size: 0.75rem; color: var(--color-text-muted); }

@media (max-width: 759px) {
  .chatbot-toggle { bottom: 5.6rem; right: var(--space-3); padding: 0.85rem; }
  .chatbot-toggle .chatbot-label { display: none; }
  .chatbot-panel { right: var(--space-2); left: var(--space-2); width: auto; bottom: 5.6rem; height: min(32rem, calc(100dvh - 7.5rem)); }
}
