:root {
  --ai-widget-accent: #e1251b;
  --ai-widget-accent-dark: #b51b14;
  --ai-widget-text: #162033;
  --ai-widget-muted: #667085;
  --ai-widget-line: #dbe3ee;
  --ai-widget-soft: #eef6ff;
}

.ai-widget {
  position: fixed;
  right: 24px;
  top: 42%;
  margin-top: 0;
  z-index: 999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.ai-widget__launcher {
  position: relative;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: linear-gradient(145deg, #ff4b3d 0%, #e1251b 55%, #c91c12 100%);
  text-decoration: none;
  text-align: center;
  letter-spacing: 0;
  box-shadow: 0 10px 28px rgba(225, 37, 27, .38), 0 3px 8px rgba(225, 37, 27, .22);
  transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
  cursor: pointer;
}

.ai-widget__launcher::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid rgba(225, 37, 27, .32);
  border-radius: 50%;
  pointer-events: none;
  animation: aiSupportPulse 2.8s ease-out infinite;
}

@keyframes aiSupportPulse {
  0% { transform: scale(.96); opacity: .9; }
  70% { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}

.ai-widget__launcher:hover {
  filter: brightness(1.04);
  transform: scale(1.06);
  box-shadow: 0 14px 32px rgba(225, 37, 27, .46), 0 5px 12px rgba(225, 37, 27, .24);
}

.ai-widget__launcher-mark {
  display: none;
}

.ai-widget__launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.ai-widget__launcher-icon svg {
  width: 28px;
  height: 28px;
  display: block;
}

.ai-widget__launcher-text {
  width: auto;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .02em;
  text-align: center;
}

.ai-widget__panel {
  position: absolute;
  right: 88px;
  top: 50%;
  transform: translateY(-50%);
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 120px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  border: 1px solid var(--ai-widget-line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(22, 32, 51, .18);
}

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

.ai-widget__header {
  min-height: 62px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ai-widget-line);
  background: #fff;
}

.ai-widget__title {
  color: var(--ai-widget-text);
  font-size: 16px;
  font-weight: 780;
}

.ai-widget__subtitle {
  margin-top: 2px;
  color: var(--ai-widget-muted);
  font-size: 12px;
}

.ai-widget__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ai-widget-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ai-widget__messages {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: #f7f9fc;
}

.ai-widget__welcome {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ai-widget-text);
  line-height: 1.55;
}

.ai-widget__welcome span {
  color: var(--ai-widget-muted);
  font-size: 13px;
}

.ai-widget__quick {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ai-widget__quick button {
  min-height: 36px;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  background: #fff;
  color: #304057;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.ai-widget__quick button:hover {
  border-color: var(--ai-widget-accent);
  color: var(--ai-widget-accent-dark);
  background: var(--ai-widget-soft);
}

.ai-widget__msg {
  display: flex;
  margin: 0 0 12px;
}

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

.ai-widget__bubble {
  max-width: 88%;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ai-widget-text);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.ai-widget__msg--user .ai-widget__bubble {
  border-color: var(--ai-widget-accent);
  background: var(--ai-widget-accent);
  color: #fff;
}

.ai-widget__bubble p {
  margin: 0 0 8px;
}

.ai-widget__bubble p:last-child {
  margin-bottom: 0;
}

.ai-widget__bubble strong {
  color: var(--ai-widget-accent-dark);
  font-weight: 760;
}

.ai-widget__msg--user .ai-widget__bubble strong {
  color: #fff;
}

.ai-widget__bubble a {
  color: var(--ai-widget-accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ai-widget__products {
  display: grid;
  gap: 8px;
  margin: 0 0 12px 0;
  padding-left: 0;
}

.ai-widget__product {
  max-width: 88%;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 11px;
}

.ai-widget__product strong {
  display: block;
  color: var(--ai-widget-text);
  font-size: 13px;
  line-height: 1.45;
}

.ai-widget__product span {
  display: block;
  margin-top: 2px;
  color: var(--ai-widget-muted);
  font-size: 12px;
}

.ai-widget__product a {
  display: inline-flex;
  margin-top: 7px;
  color: var(--ai-widget-accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.ai-widget__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--ai-widget-line);
  background: #fff;
}

.ai-widget__composer textarea {
  width: 100%;
  min-height: 40px;
  max-height: 112px;
  resize: none;
  border: 1px solid var(--ai-widget-line);
  border-radius: 8px;
  outline: none;
  padding: 9px 10px;
  color: var(--ai-widget-text);
  line-height: 1.5;
}

.ai-widget__composer textarea:focus {
  border-color: var(--ai-widget-accent);
  box-shadow: 0 0 0 3px rgba(18, 104, 179, .1);
}

.ai-widget__composer button {
  min-width: 68px;
  border: 1px solid var(--ai-widget-accent);
  border-radius: 8px;
  background: var(--ai-widget-accent);
  color: #fff;
  cursor: pointer;
}

.ai-widget__composer button:disabled {
  opacity: .65;
  cursor: wait;
}

.ai-widget__foot {
  padding: 0 12px 10px;
  color: var(--ai-widget-muted);
  background: #fff;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 768px) {
  .ai-widget {
    display: block;
    right: 14px;
    top: auto;
    bottom: 82px;
  }
  .ai-widget__launcher { width: 58px; height: 58px; }
  .ai-widget__launcher-icon,
  .ai-widget__launcher-icon svg { width: 23px; height: 23px; }
  .ai-widget__launcher-text { font-size: 9px; }
  .ai-widget__launcher::after { inset: -4px; }
  .ai-widget__panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 150px;
    transform: none;
    width: auto;
    height: min(66vh, 560px);
  }
}
