.ai-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 1001;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #ef1111;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(239, 17, 17, 0.35);
}

.ai-chat-launcher i {
  font-size: 25px;
}

.ai-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 150px;
  z-index: 1002;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 180px));
  height: min(520px, calc(100dvh - 180px));
  overflow: hidden;
  border: 1px solid rgba(127, 127, 127, 0.28);
  border-radius: 16px;
  background: var(--body-color, #fff);
  color: var(--text-color, #1a1a1a);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
}

.ai-chat-panel[hidden] {
  display: none;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.22);
}

.ai-chat-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.ai-chat-header > div:first-child > span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.7;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-location,
.ai-chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid rgba(127, 127, 127, 0.32);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.ai-chat-location:hover,
.ai-chat-close:hover {
  border-color: #ef1111;
  color: #ef1111;
}

.ai-chat-close {
  width: 34px;
  padding: 0;
  font-size: 20px;
}

.ai-chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
}

.ai-chat-message {
  max-width: 88%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.12);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-chat-message.user {
  align-self: flex-end;
  background: #ef1111;
  color: #fff;
}

.ai-chat-message.waiting,
.ai-chat-message.error {
  opacity: 0.75;
}

.ai-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(127, 127, 127, 0.22);
}

.ai-chat-input-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 10px;
  background: var(--search-bar, #f4f4f4);
  color: var(--text-color, #1a1a1a);
  font: inherit;
  font-size: 14px;
}

.ai-chat-form input:focus-visible {
  outline: 2px solid #ef1111;
  outline-offset: 1px;
}

.ai-chat-send {
  display: grid;
  place-items: center;
  width: 42px;
  border: 0;
  border-radius: 10px;
  background: #ef1111;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.ai-chat-send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.ai-chat-disclaimer {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.68;
}

.ai-chat-launcher:focus-visible,
.ai-chat-location:focus-visible,
.ai-chat-close:focus-visible,
.ai-chat-send:focus-visible {
  outline: 3px solid rgba(239, 17, 17, 0.55);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .ai-chat-launcher {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .ai-chat-panel {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(150px + env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 32px));
    height: min(520px, calc(100vh - 190px - env(safe-area-inset-bottom)));
    height: min(520px, calc(100dvh - 190px - env(safe-area-inset-bottom)));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-launcher {
    transition: none;
  }
}
