.ollama-support {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 9000;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.ollama-support-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: right;
  max-width: min(280px, calc(100vw - 24px));
}

.ollama-support-toggle:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 4px;
  border-radius: 12px;
}

.ollama-support-bubble {
  position: relative;
  background: #fff;
  color: #333;
  border: 1px solid #dbe3f0;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
  animation: ollama-bob 3.2s ease-in-out infinite;
}

.ollama-support-bubble::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -8px;
  border: 8px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 2px 0 #dbe3f0);
}

.ollama-support-label {
  display: block;
  font-size: 11px;
  color: #2563eb;
  font-weight: 700;
  margin-bottom: 4px;
}

.ollama-support-msg {
  display: block;
  min-height: 2.9em;
}

.ollama-support-avatar-wrap {
  position: relative;
  display: inline-block;
}

.ollama-support-avatar,
.ollama-support-head img {
  background: transparent;
}

.ollama-support-avatar {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.12));
  transition: transform 0.2s ease;
}

.ollama-support-toggle:hover .ollama-support-avatar,
.ollama-support-toggle:focus-visible .ollama-support-avatar {
  transform: scale(1.06) rotate(-3deg);
}

.ollama-support-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #dbe3f0;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  padding: 14px 14px 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.ollama-support.is-open .ollama-support-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ollama-support.is-open .ollama-support-bubble {
  animation: none;
}

.ollama-support-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.ollama-support-head img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.ollama-support-head strong {
  display: block;
  font-size: 15px;
}

.ollama-support-head span {
  display: block;
  font-size: 12px;
  color: #666;
}

.ollama-support-links {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.ollama-support-links a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  color: #1d3a8a;
  background: #eef3ff;
  border: 1px solid #dbeafe;
}

.ollama-support-links a.primary {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

.ollama-support-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: #777;
}

.ollama-support-chat-label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #1d3a8a;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ollama-support-chat {
  flex: 1 1 auto;
  min-height: 140px;
  max-height: 240px;
  overflow-y: auto;
  margin: 0 0 10px;
  padding: 8px;
  background: #f7f9fc;
  border: 1px solid #e5e8ef;
  border-radius: 12px;
}

.ollama-chat-msg {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ollama-chat-msg:last-child {
  margin-bottom: 0;
}

.ollama-chat-bot {
  background: #fff;
  border: 1px solid #dbe3f0;
  margin-right: 12px;
}

.ollama-chat-user {
  background: #2563eb;
  color: #fff;
  margin-left: 24px;
  text-align: right;
}

.ollama-chat-msg a {
  color: inherit;
  text-decoration: underline;
}

.ollama-chat-user a {
  color: #fff;
}

.ollama-chat-pending {
  opacity: 0.7;
  font-style: italic;
}

.ollama-support-form {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  padding: 8px;
  background: #eef3ff;
  border: 2px solid #93c5fd;
  border-radius: 12px;
}

.ollama-support-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #dbe3f0;
  border-radius: 10px;
  font: inherit;
}

.ollama-support-form button {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.ollama-support-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ollama-support-links-wrap summary {
  cursor: pointer;
  font-size: 12px;
  color: #2563eb;
  font-weight: 600;
  margin-bottom: 6px;
}

.ollama-support-links-wrap[open] summary {
  margin-bottom: 8px;
}

.ollama-support-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #555;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

@keyframes ollama-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .ollama-support-bubble {
    animation: none;
  }
  .ollama-support-panel,
  .ollama-support-avatar {
    transition: none;
  }
}

@media (max-width: 480px) {
  .ollama-support-avatar {
    width: 60px;
    height: 60px;
  }
}
