/* CryingSea_AI floating assistant */
:root {
  --cs-ai-primary: #006eff;
  --cs-ai-primary-hover: #0052d9;
  --cs-ai-bg: #ffffff;
  --cs-ai-text: #212121;
  --cs-ai-muted: #8c8c8c;
  --cs-ai-border: #e5e5e5;
  --cs-ai-soft: #f5f7fa;
  --cs-ai-z: 1040;
}

#cryingsea-ai-root[hidden] {
  display: none !important;
}

.cs-ai-fab {
  position: fixed;
  right: 0;
  bottom: 140px;
  z-index: var(--cs-ai-z);
  width: 28px;
  min-height: 92px;
  height: auto;
  margin: 0;
  padding: 8px 0 10px;
  border: 1px solid #c0c4cc;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #fff;
  color: #8c8c8c;
  cursor: pointer;
  box-shadow: -2px 2px 10px rgba(15, 23, 42, 0.08);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.cs-ai-fab:hover {
  background: #fff;
  color: #595959;
  transform: translateX(-2px);
  box-shadow: -4px 4px 14px rgba(15, 23, 42, 0.12);
}
.cs-ai-fab:active {
  transform: translateX(0);
}
.cs-ai-fab__icon,
.cs-ai-fab svg {
  width: 15px;
  height: 15px;
  display: block;
  flex: 0 0 auto;
  color: #8c8c8c;
}
.cs-ai-fab:hover .cs-ai-fab__icon,
.cs-ai-fab:hover svg {
  color: #595959;
}
.cs-ai-fab__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: inherit;
  user-select: none;
}
.cs-ai-fab__ai {
  display: block;
  writing-mode: horizontal-tb;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
.cs-ai-fab__zh {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.cs-ai-panel {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: calc(var(--cs-ai-z) + 1);
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 120px));
  background: var(--cs-ai-bg);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, 18px, 0) scale(0.96);
  transform-origin: right bottom;
  transition: opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.cs-ai-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}

.cs-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--cs-ai-border);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
}
.cs-ai-head__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--cs-ai-text);
  margin: 0;
}
.cs-ai-head__sub {
  font-size: 11px;
  color: var(--cs-ai-muted);
  margin: 2px 0 0;
}
.cs-ai-head__close {
  border: 0;
  background: transparent;
  color: var(--cs-ai-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.cs-ai-hello {
  padding: 16px 16px 8px;
  flex: 0 0 auto;
  background: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.22s ease,
    padding 0.22s ease, margin 0.22s ease;
}
.cs-ai-hello.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
.cs-ai-hello.is-enter {
  animation: cs-ai-fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cs-ai-hello__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--cs-ai-text);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-ai-hello__sub {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--cs-ai-muted);
  line-height: 1.4;
}

.cs-ai-tabs {
  display: flex;
  gap: 2px;
  margin: 10px 12px 0;
  padding: 3px;
  border: 0;
  border-radius: 10px;
  background: #eef1f5;
  flex: 0 0 auto;
}
.cs-ai-tab {
  flex: 1;
  position: relative;
  height: 30px;
  border: 0;
  background: transparent;
  color: #8c8c8c;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 0 10px;
  cursor: pointer;
  border-radius: 8px;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.cs-ai-tab:hover {
  color: #595959;
}
.cs-ai-tab.is-active {
  background: #fff;
  color: var(--cs-ai-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}
.cs-ai-tab:active {
  opacity: 0.9;
}

.cs-ai-suggest {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 12px 10px;
  flex: 0 0 auto;
  background: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.cs-ai-suggest.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}
.cs-ai-suggest:empty {
  display: none;
  padding: 0;
}
.cs-ai-chip {
  border: 1px solid transparent;
  background: #fff;
  color: var(--cs-ai-text);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  max-width: 100%;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  opacity: 1;
  transform: translateY(0);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease,
    transform 0.15s ease;
}
.cs-ai-panel.is-open .cs-ai-chip {
  animation: cs-ai-chip-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cs-ai-chip:hover {
  border-color: var(--cs-ai-primary);
  color: var(--cs-ai-primary);
  box-shadow: 0 2px 8px rgba(0, 110, 255, 0.16);
}
.cs-ai-chip:active {
  transform: scale(0.96);
}
.cs-ai-chip.is-pressed {
  animation: cs-ai-chip-press 0.28s ease;
}

.cs-ai-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--cs-ai-soft);
}
.cs-ai-messages {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: none;
}
.cs-ai-msg {
  max-width: 92%;
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  word-break: break-word;
  animation: cs-ai-msg-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cs-ai-msg--user {
  align-self: flex-end;
  background: var(--cs-ai-primary);
  color: #fff;
  white-space: pre-wrap;
  box-shadow: 0 2px 10px rgba(0, 110, 255, 0.22);
  animation-name: cs-ai-msg-user-in;
}
.cs-ai-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--cs-ai-text);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  animation-name: cs-ai-msg-bot-in;
}
.cs-ai-msg--err {
  align-self: stretch;
  background: #fff5f5;
  color: #c0392b;
  box-shadow: 0 2px 10px rgba(192, 57, 43, 0.12);
}
.cs-ai-msg--bot .cs-ai-md > *:first-child {
  margin-top: 0;
}
.cs-ai-msg--bot .cs-ai-md > *:last-child {
  margin-bottom: 0;
}
.cs-ai-md p {
  margin: 0 0 0.55em;
}
.cs-ai-md p:last-child {
  margin-bottom: 0;
}
.cs-ai-md strong {
  font-weight: 600;
}
.cs-ai-md em {
  font-style: italic;
}
.cs-ai-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: #f3f5f7;
  padding: 1px 5px;
  border-radius: 4px;
}
.cs-ai-md pre {
  margin: 0.5em 0;
  padding: 8px 10px;
  background: #f3f5f7;
  border-radius: 8px;
  overflow: auto;
}
.cs-ai-md pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}
.cs-ai-md ul,
.cs-ai-md ol {
  margin: 0.4em 0 0.55em;
  padding-left: 1.25em;
}
.cs-ai-md li {
  margin: 0.2em 0;
}
.cs-ai-md a {
  color: var(--cs-ai-primary);
  text-decoration: none;
}
.cs-ai-md a:hover {
  text-decoration: underline;
}
.cs-ai-md h1,
.cs-ai-md h2,
.cs-ai-md h3 {
  margin: 0.55em 0 0.35em;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.cs-ai-hello.is-hidden,
.cs-ai-suggest.is-hidden {
  display: none !important;
}

@keyframes cs-ai-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes cs-ai-chip-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes cs-ai-chip-press {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes cs-ai-msg-user-in {
  from {
    opacity: 0;
    transform: translate3d(16px, 8px, 0) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
@keyframes cs-ai-msg-bot-in {
  from {
    opacity: 0;
    transform: translate3d(-16px, 8px, 0) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
@keyframes cs-ai-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.cs-ai-head__sub--waiting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #4e5969;
}
.cs-ai-waiting__spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid rgba(22, 119, 255, 0.18);
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: portal-boot-spin 0.75s linear infinite;
}
.cs-ai-waiting__text {
  font-size: 12px;
  line-height: 1.4;
  color: #4e5969;
}
@keyframes portal-boot-spin {
  to {
    transform: rotate(360deg);
  }
}
.cs-ai-input:disabled,
.cs-ai-send:disabled,
.cs-ai-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cs-ai-foot {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}
.cs-ai-input {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 42px;
  font-family: inherit;
  color: #333;
  background: #f2f4f7;
  box-shadow: inset 0 0 0 1px transparent;
  outline: none;
  overflow: hidden;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.cs-ai-input::placeholder {
  color: #9aa3af;
  line-height: 42px;
}
.cs-ai-input:focus {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 110, 255, 0.18), 0 2px 8px rgba(15, 23, 42, 0.06);
}
.cs-ai-input:disabled {
  background: #eceff3;
}
.cs-ai-send {
  box-sizing: border-box;
  flex: 0 0 auto;
  height: 42px;
  min-width: 72px;
  border: 0;
  border-radius: 12px;
  background: var(--cs-ai-primary);
  color: #fff;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 110, 255, 0.28);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.cs-ai-send:hover:not(:disabled) {
  background: var(--cs-ai-primary-hover);
  box-shadow: 0 4px 14px rgba(0, 110, 255, 0.34);
  transform: translateY(-1px);
}
.cs-ai-send:active:not(:disabled) {
  transform: translateY(0);
}

/* 导购高亮：单层描边，不自动叠双环 */
.cart-pro-card.is-ai-guide {
  outline: 2px solid var(--cs-ai-primary) !important;
  outline-offset: 0;
  box-shadow: none !important;
  transition: outline-color 0.35s ease;
}
.cart-pro-card.is-ai-guide.is-ai-guide-fade {
  outline-color: transparent !important;
}

@media (max-width: 576px) {
  .cs-ai-fab {
    right: 0;
    bottom: 110px;
    width: 26px;
  }
  .cs-ai-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 72px;
    height: min(70vh, 520px);
  }
}

/* 强制与用户中心一致，避免购物车主题覆盖 input/button */
#cryingsea-ai-root .cs-ai-foot {
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}
#cryingsea-ai-root .cs-ai-input,
#cryingsea-ai-root input.cs-ai-input {
  box-sizing: border-box !important;
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 12px !important;
  padding: 0 14px !important;
  font-size: 13px !important;
  line-height: 42px !important;
  font-family: inherit !important;
  font-weight: 400 !important;
  color: #333 !important;
  background: #f2f4f7 !important;
  box-shadow: none !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}
#cryingsea-ai-root .cs-ai-input::placeholder,
#cryingsea-ai-root input.cs-ai-input::placeholder {
  color: #9aa3af !important;
  opacity: 1 !important;
}
#cryingsea-ai-root .cs-ai-input:focus,
#cryingsea-ai-root input.cs-ai-input:focus {
  background: #fff !important;
  box-shadow: 0 0 0 2px rgba(0, 110, 255, 0.18), 0 2px 8px rgba(15, 23, 42, 0.06) !important;
}
html body #cryingsea-ai-root .cs-ai-send,
html body #cryingsea-ai-root button.cs-ai-send {
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
  width: auto !important;
  height: 42px !important;
  min-width: 72px !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: #006eff !important;
  color: #fff !important;
  padding: 0 16px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  letter-spacing: 0.02em !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 10px rgba(0, 110, 255, 0.28) !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  text-shadow: none !important;
  transform: none !important;
}
html body #cryingsea-ai-root .cs-ai-send:hover:not(:disabled),
html body #cryingsea-ai-root button.cs-ai-send:hover:not(:disabled) {
  background: #0052d9 !important;
  box-shadow: 0 4px 14px rgba(0, 110, 255, 0.34) !important;
  transform: translateY(-1px) !important;
}
html body #cryingsea-ai-root .cs-ai-tabs {
  display: flex !important;
  gap: 2px !important;
  margin: 10px 12px 0 !important;
  padding: 3px !important;
  background: #eef1f5 !important;
  border: 0 !important;
  border-radius: 10px !important;
}
html body #cryingsea-ai-root .cs-ai-tab,
html body #cryingsea-ai-root button.cs-ai-tab {
  flex: 1 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 30px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: #8c8c8c !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1 !important;
  padding: 0 10px !important;
  margin: 0 !important;
  box-shadow: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  transform: none !important;
}
html body #cryingsea-ai-root .cs-ai-tab.is-active,
html body #cryingsea-ai-root button.cs-ai-tab.is-active {
  background: #fff !important;
  color: #006eff !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1) !important;
}
html body #cryingsea-ai-root .cs-ai-tab:hover:not(.is-active),
html body #cryingsea-ai-root button.cs-ai-tab:hover:not(.is-active) {
  background: transparent !important;
  color: #595959 !important;
}
