:root {
  --ai-chatbot-bg: #0f2b1d;
  --ai-chatbot-card: rgba(14, 22, 18, 0.96);
  --ai-chatbot-text: #f5f6f7;
  --ai-chatbot-muted: rgba(245,246,247,0.7);
  --ai-chatbot-accent: #c8a96a;
  --ai-chatbot-shadow: 0 16px 40px rgba(0,0,0,0.25);
  --ai-chatbot-radius: 16px;
  --ai-chatbot-z: 70;
}

.ai-chatbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--ai-chatbot-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: inherit;
}

.ai-chatbot__greeting {
  display: none;
  align-items: flex-end;
}

.ai-chatbot__greeting.is-visible {
  display: flex;
}

.ai-chatbot__greeting-bubble {
  max-width: 240px;
  background: var(--ai-chatbot-card);
  color: var(--ai-chatbot-text);
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: var(--ai-chatbot-shadow);
  font-size: 0.9rem;
  line-height: 1.4;
}

.ai-chatbot__panel {
  width: min(360px, 90vw);
  background: var(--ai-chatbot-card);
  color: var(--ai-chatbot-text);
  border-radius: var(--ai-chatbot-radius);
  box-shadow: var(--ai-chatbot-shadow);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  bottom: 78px;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-chatbot__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ai-chatbot__panel.is-minimized {
  height: auto;
}

.ai-chatbot__panel.is-minimized .ai-chatbot__messages,
.ai-chatbot__panel.is-minimized .ai-chatbot__composer {
  display: none;
}

.ai-chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(15, 43, 29, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.ai-chatbot__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chatbot__title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-size: 0.95rem;
}

.ai-chatbot__title-main {
  font-weight: 600;
}

.ai-chatbot__title-sub {
  font-size: 0.78rem;
  color: var(--ai-chatbot-muted);
}

.ai-chatbot__minimize,
.ai-chatbot__close {
  background: transparent;
  border: none;
  color: var(--ai-chatbot-text);
  font-size: 1.1rem;
  cursor: pointer;
}

.ai-chatbot__minimize {
  font-size: 1.2rem;
  line-height: 1;
  transform: translateY(-2px);
}

.ai-chatbot__messages {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.ai-chatbot__msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ai-chatbot__msg--user {
  justify-content: flex-end;
}

.ai-chatbot__bubble {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  color: var(--ai-chatbot-text);
  max-width: 85%;
  font-size: 0.9rem;
  line-height: 1.4;
}

.ai-chatbot__msg--user .ai-chatbot__bubble {
  background: rgba(200,169,106,0.18);
  border: 1px solid rgba(200,169,106,0.4);
}

.ai-chatbot__typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 999px;
  background: var(--ai-chatbot-muted);
  animation: ai-chatbot-bounce 1.2s infinite ease-in-out;
}

.ai-chatbot__typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chatbot__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-chatbot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.ai-chatbot__composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(15, 43, 29, 0.85);
}

.ai-chatbot__input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--ai-chatbot-text);
  border-radius: 10px;
  padding: 8px 10px;
}

.ai-chatbot__send {
  background: var(--ai-chatbot-accent);
  border: none;
  color: #0b1a12;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.ai-chatbot__launcher {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.15);
  background: linear-gradient(135deg, rgba(200,169,106,0.9), rgba(13,70,43,0.9));
  box-shadow: var(--ai-chatbot-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-chatbot__launcher:hover {
  transform: translateY(-2px) scale(1.02);
}

.ai-chatbot__launcher img {
  width: 40px;
  height: 40px;
}

.grammar-ai {
  background: rgba(15, 43, 29, 0.04);
  border: 1px solid rgba(15, 43, 29, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
}

.grammar-ai__row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.grammar-ai__input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
}

.grammar-ai__button {
  background: #0f2b1d;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.grammar-ai__output {
  background: #f1ffee0d;
  border-radius: 12px;
  border: 1px solid rgb(255 255 255 / 8%);
  padding: 12px;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .ai-chatbot { right: 10px; bottom: 10px; gap: 8px; }
  .ai-chatbot__panel { width: min(300px, 90vw); border-radius: 14px; bottom: 62px; }
  .ai-chatbot__messages { max-height: 240px; padding: 10px; }
  .ai-chatbot__launcher { width: 48px; height: 48px; }
  .ai-chatbot__launcher img { width: 32px; height: 32px; }
  .ai-chatbot__header { padding: 10px 12px; }
  .ai-chatbot__title { font-size: 0.85rem; }
  .ai-chatbot__bubble { font-size: 0.82rem; }
  .ai-chatbot__composer { padding: 10px; }
  .ai-chatbot__input { font-size: 0.85rem; padding: 7px 9px; }
  .ai-chatbot__send { font-size: 0.85rem; padding: 7px 10px; }
  .grammar-ai__row { flex-direction: column; }
}
