.ai-assistant-widget {
  position: fixed;
  width: 58px;
  min-height: 58px;
  right: 18px;
  bottom: 18px;
  z-index: 10020;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.ai-assistant-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.ai-assistant-idle-bubble {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  width: min(290px, calc(100vw - 32px));
  padding: 12px 12px 12px 14px;
  border: 1px solid rgba(11, 79, 143, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 42px rgba(27, 36, 40, 0.18);
}

.ai-assistant-bubble--info {
  border-color: rgba(11, 79, 143, 0.22);
  background: #eef6ff;
}

.ai-assistant-bubble--hint {
  border-color: rgba(239, 126, 29, 0.42);
  background: linear-gradient(135deg, #ffb15a 0%, #ef7e1d 100%);
}

.ai-assistant-bubble--fallback {
  border-color: rgba(182, 149, 51, 0.24);
  background: #fff7da;
}

.ai-assistant-bubble--error {
  border-color: rgba(177, 63, 63, 0.24);
  background: #fff0f0;
}

.ai-assistant-idle-bubble[hidden] {
  display: none;
}

.ai-assistant-hidden .ai-assistant-idle-bubble,
.ai-assistant-hidden .ai-assistant-panel,
.ai-assistant-hidden .ai-assistant-toggle {
  pointer-events: none;
}

.ai-assistant-widget--align-start .ai-assistant-idle-bubble,
.ai-assistant-widget--align-start .ai-assistant-panel {
  right: auto;
  left: 0;
}

.ai-assistant-idle-text {
  margin: 0;
  color: #1b2428;
  font-size: 14px;
  line-height: 1.45;
}

.ai-assistant-bubble--info .ai-assistant-idle-text {
  color: #0b4f8f;
}

.ai-assistant-bubble--hint .ai-assistant-idle-text {
  color: #000;
}

.ai-assistant-bubble--fallback .ai-assistant-idle-text {
  color: #4a3d16;
}

.ai-assistant-bubble--error .ai-assistant-idle-text {
  color: #8f2a2a;
}

.ai-assistant-idle-close {
  width: 28px;
  height: 28px;
  padding: 0;
  color: #5f6d73;
  border: 0;
  border-radius: 999px;
  background: #eef3f8;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.ai-assistant-toggle {
  --ai-assistant-toggle-shadow-rest: 0 16px 34px rgba(88, 101, 109, 0.28);
  --ai-assistant-toggle-shadow-pulse: 0 18px 40px rgba(88, 101, 109, 0.34);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #8a949b 0%, #67737b 100%);
  box-shadow: var(--ai-assistant-toggle-shadow-rest);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.ai-assistant-dragging .ai-assistant-toggle {
  cursor: grabbing;
}

.ai-assistant-widget--active .ai-assistant-toggle {
  --ai-assistant-toggle-shadow-rest: 0 16px 34px rgba(11, 79, 143, 0.28);
  --ai-assistant-toggle-shadow-pulse: 0 18px 40px rgba(11, 79, 143, 0.36);
  background: linear-gradient(135deg, #0b4f8f 0%, #0f766e 100%);
  box-shadow: var(--ai-assistant-toggle-shadow-rest);
}

.ai-assistant-widget--target-hover .ai-assistant-toggle {
  --ai-assistant-toggle-shadow-rest: 0 18px 38px rgba(239, 126, 29, 0.34);
  --ai-assistant-toggle-shadow-pulse: 0 20px 42px rgba(239, 126, 29, 0.42);
  background: linear-gradient(135deg, #ffb15a 0%, #ef7e1d 100%);
  box-shadow: var(--ai-assistant-toggle-shadow-rest);
}

.ai-assistant-pulse {
  animation: ai-assistant-pulse 1.8s ease-in-out infinite;
}

.ai-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: grid;
  gap: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 110px));
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(11, 79, 143, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 42px rgba(27, 36, 40, 0.18);
}

.ai-assistant-panel[hidden] {
  display: none;
}

.ai-assistant-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.ai-assistant-title {
  margin: 0;
  font-size: 18px;
}

.ai-assistant-close {
  min-width: 36px;
  height: 36px;
  padding: 0;
  color: #0b4f8f;
  border: 1px solid rgba(11, 79, 143, 0.18);
  border-radius: 999px;
  background: #f6f8fb;
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

.ai-assistant-messages {
  display: grid;
  gap: 10px;
  min-height: 140px;
  max-height: 270px;
  padding-right: 4px;
  overflow-y: auto;
}

.ai-assistant-message {
  padding: 10px 12px;
  border-radius: 10px;
  line-height: 1.4;
}

.ai-assistant-message--assistant {
  color: #000;
  background: linear-gradient(180deg, #478A84 0%, #7E8B92 100%);
}

.ai-assistant-message--notice {
  border: 1px solid rgba(181, 151, 91, 0.28);
  background: #fff9ed;
}

.ai-assistant-message--user {
  background: #eaf5f1;
}

.ai-assistant-message-text {
  margin: 0;
}

.ai-assistant-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-assistant-inline-action {
  min-height: 38px;
  padding: 0 12px;
  color: #1b2428;
  border: 1px solid rgba(11, 79, 143, 0.18);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ai-assistant-inline-action--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #9fcfff 0%, #ffedaa 100%);
}

.ai-assistant-form {
  display: grid;
  gap: 10px;
}

.ai-assistant-input {
  width: 100%;
  min-height: 92px;
  padding: 12px;
  color: #1b2428;
  border: 1px solid rgba(11, 79, 143, 0.18);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  resize: vertical;
}

.ai-assistant-actions {
  display: flex;
  justify-content: flex-end;
}

.ai-assistant-send {
  min-height: 42px;
  padding: 0 16px;
  color: #000;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #9fcfff 0%, #ffedaa 100%);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ai-assistant-note {
  margin: 0;
  color: #5f6d73;
  font-size: 12px;
  line-height: 1.35;
}

.ai-assistant-status {
  min-height: 18px;
  margin: 0;
  color: #5f6d73;
  font-size: 12px;
}

.ai-assistant-target-highlight {
  outline: 2px solid rgba(239, 126, 29, 0.55);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(255, 177, 90, 0.18);
  transition: outline-color 0.18s ease, box-shadow 0.18s ease;
}

@keyframes ai-assistant-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: var(--ai-assistant-toggle-shadow-rest);
  }

  50% {
    transform: scale(1.04);
    box-shadow: var(--ai-assistant-toggle-shadow-pulse);
  }
}

@media (max-width: 640px) {
  .ai-assistant-widget {
    width: 58px;
    right: 12px;
    bottom: 12px;
  }

  .ai-assistant-idle-bubble {
    right: 0;
    bottom: 70px;
    width: min(280px, calc(100vw - 24px));
  }

  .ai-assistant-panel {
    right: 0;
    width: min(340px, calc(100vw - 16px));
    bottom: 70px;
  }
}
