:root {
  --ai-widget-accent: #16a34a;
  --ai-widget-accent-dark: #12813b;
  --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 {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--ai-widget-accent);
  text-decoration: none;
  text-align: center;
  letter-spacing: 0;
  box-shadow: 0 6px 20px rgba(22, 163, 74, .28), 0 2px 4px rgba(22, 163, 74, .14);
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
  cursor: pointer;
}

.ai-widget__launcher:hover {
  background: var(--ai-widget-accent-dark);
  transform: scale(1.08);
  box-shadow: 0 10px 26px rgba(22, 163, 74, .36), 0 4px 8px rgba(22, 163, 74, .18);
}

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

.ai-widget__launcher-text {
  width: auto;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.ai-widget__panel {
  position: absolute;
  right: 76px;
  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: none; }
}
