#ys-supply-ai-root {
  --ai-green: #123c31;
  --ai-green-2: #1d5a49;
  --ai-mint: #dcebe3;
  --ai-cream: #f8f6ef;
  --ai-ink: #17231f;
  --ai-muted: #68746f;
  --ai-border: rgba(24, 71, 58, 0.14);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ai-ink);
}

.ys-ai-launcher {
  position: fixed;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 1200;
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(135deg, #163f34, #26725b);
  box-shadow: 0 14px 36px rgba(14, 53, 42, 0.25);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ys-ai-alert-badge {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  padding: 0 4px;
  color: #6a2b20;
  background: #ffd8bd;
  font-size: 10px;
}

.ys-ai-alert-badge[hidden] {
  display: none;
}

.ys-ai-authenticated .ys-ai-launcher {
  display: flex;
}

.ys-ai-spark {
  font-size: 18px;
  color: #d4e9a5;
}

.ys-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1201;
  visibility: hidden;
  opacity: 0;
  background: rgba(8, 23, 18, 0.3);
  backdrop-filter: blur(2px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.ys-ai-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1202;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  width: min(520px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: rgba(250, 249, 244, 0.98);
  box-shadow: 0 28px 70px rgba(7, 30, 23, 0.28);
  transform: translateX(calc(100% + 32px));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.ys-ai-open .ys-ai-backdrop {
  visibility: visible;
  opacity: 1;
}

.ys-ai-open .ys-ai-panel {
  transform: translateX(0);
}

.ys-ai-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 85% -20%, rgba(220, 235, 166, 0.26), transparent 42%),
    linear-gradient(145deg, #102f28, #1c5948);
}

.ys-ai-eyebrow {
  margin-bottom: 5px;
  color: #cfe4a5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.ys-ai-header h2 {
  margin: 0;
  color: inherit;
  font-size: 22px;
  line-height: 1.25;
}

.ys-ai-header p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.ys-ai-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.ys-ai-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  color: var(--ai-green);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
}

.ys-ai-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ys-ai-header .ys-ai-icon-btn {
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.ys-ai-conversation-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ai-border);
  background: #fff;
}

.ys-ai-alerts {
  max-height: 132px;
  overflow: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--ai-border);
  background: #fffaf0;
}

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

.ys-ai-alerts-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #725b26;
  font-size: 11px;
}

.ys-ai-alerts-title span {
  opacity: 0.7;
}

.ys-ai-alerts-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
}

.ys-ai-alert {
  min-width: 154px;
  border: 1px solid #e7d9af;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  color: #4c3d1c;
  background: #fff;
  cursor: pointer;
}

.ys-ai-alert span,
.ys-ai-alert small {
  display: block;
}

.ys-ai-alert span {
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 750;
}

.ys-ai-alert small {
  overflow: hidden;
  color: #796b4a;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ys-ai-alert-danger {
  border-color: #e2b5ad;
  background: #fff6f3;
}

.ys-ai-conversation-select {
  min-width: 0;
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ai-ink);
  background: #f8faf8;
  font: inherit;
  font-size: 13px;
}

.ys-ai-quick {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--ai-border);
  scrollbar-width: none;
}

.ys-ai-quick::-webkit-scrollbar {
  display: none;
}

.ys-ai-quick button {
  flex: 0 0 auto;
  border: 1px solid rgba(30, 91, 72, 0.17);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--ai-green-2);
  background: #f2f7f3;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.ys-ai-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 28px;
  scroll-behavior: smooth;
}

.ys-ai-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 32px;
  text-align: center;
}

.ys-ai-empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 15px;
  border-radius: 18px;
  color: #d7efa0;
  background: var(--ai-green);
  font-size: 24px;
  box-shadow: 0 12px 30px rgba(17, 67, 52, 0.18);
}

.ys-ai-empty h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.ys-ai-empty p {
  max-width: 330px;
  margin: 0;
  color: var(--ai-muted);
  font-size: 13px;
  line-height: 1.75;
}

.ys-ai-message {
  margin-bottom: 18px;
}

.ys-ai-message-user {
  margin-left: 48px;
}

.ys-ai-message-label {
  margin: 0 0 6px 4px;
  color: var(--ai-muted);
  font-size: 11px;
  font-weight: 700;
}

.ys-ai-message-user .ys-ai-message-label {
  text-align: right;
}

.ys-ai-bubble {
  overflow-wrap: anywhere;
  border: 1px solid var(--ai-border);
  border-radius: 6px 18px 18px 18px;
  padding: 13px 15px;
  background: #fff;
  font-size: 14px;
  line-height: 1.72;
  box-shadow: 0 5px 18px rgba(15, 50, 40, 0.04);
}

.ys-ai-message-user .ys-ai-bubble {
  border: 0;
  border-radius: 18px 6px 18px 18px;
  color: #fff;
  background: linear-gradient(145deg, #194b3d, #236651);
}

.ys-ai-message-actions {
  display: flex;
  gap: 5px;
  margin: 5px 0 0 4px;
}

.ys-ai-message-actions button {
  border: 0;
  padding: 3px 6px;
  color: var(--ai-muted);
  background: transparent;
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.ys-ai-message-actions button:hover {
  color: var(--ai-green-2);
}

.ys-ai-bubble p,
.ys-ai-bubble ul,
.ys-ai-bubble ol,
.ys-ai-bubble blockquote {
  margin: 0 0 10px;
}

.ys-ai-bubble > :last-child {
  margin-bottom: 0;
}

.ys-ai-bubble h3,
.ys-ai-bubble h4,
.ys-ai-bubble h5,
.ys-ai-bubble h6 {
  margin: 16px 0 8px;
  line-height: 1.4;
}

.ys-ai-bubble li + li {
  margin-top: 4px;
}

.ys-ai-bubble blockquote {
  border-left: 3px solid #7dab8d;
  padding: 7px 11px;
  color: #53615b;
  background: #f2f7f3;
}

.ys-ai-bubble code {
  border-radius: 5px;
  padding: 2px 5px;
  color: #245d4b;
  background: #edf4ef;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ys-ai-code {
  overflow: hidden;
  margin: 10px 0;
  border-radius: 12px;
  background: #15251f;
}

.ys-ai-code > span {
  display: block;
  padding: 7px 11px;
  color: #bcd1c7;
  font-size: 10px;
  font-weight: 700;
}

.ys-ai-code pre {
  overflow-x: auto;
  margin: 0;
  padding: 12px;
  color: #e4eee9;
}

.ys-ai-code code {
  padding: 0;
  color: inherit;
  background: none;
}

.ys-ai-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
}

.ys-ai-table-wrap table {
  width: 100%;
  min-width: 380px;
  border-collapse: collapse;
  font-size: 12px;
}

.ys-ai-table-wrap th,
.ys-ai-table-wrap td {
  border: 1px solid #dfe8e2;
  padding: 8px 9px;
  text-align: left;
  white-space: nowrap;
}

.ys-ai-table-wrap th {
  color: #254b3f;
  background: #eef5f0;
}

.ys-ai-preview {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #d7bd74;
  border-radius: 16px;
  padding: 14px;
  background: #fffaf0;
}

.ys-ai-preview-error {
  border-color: #e3b5b0;
  background: #fff4f2;
}

.ys-ai-preview-confirmed {
  border-color: #a8c9b3;
  background: #f2f8f3;
}

.ys-ai-preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #694f12;
  font-weight: 800;
}

.ys-ai-preview-confirmed .ys-ai-preview-title {
  color: #246044;
}

.ys-ai-preview-title small {
  font-weight: 500;
  opacity: 0.7;
}

.ys-ai-preview-grid {
  display: grid;
  gap: 7px;
}

.ys-ai-preview-grid > div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
}

.ys-ai-preview-grid span {
  color: var(--ai-muted);
}

.ys-ai-preview-grid strong {
  overflow-wrap: anywhere;
}

.ys-ai-impact {
  margin: 11px 0;
  color: #6b5a2a;
  font-size: 12px;
  line-height: 1.6;
}

.ys-ai-confirm,
.ys-ai-refresh {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  background: #9a741b;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.ys-ai-refresh {
  background: var(--ai-green-2);
}

.ys-ai-confirm:disabled {
  opacity: 0.55;
}

.ys-ai-status {
  min-height: 20px;
  padding: 2px 20px 4px;
  color: var(--ai-green-2);
  font-size: 11px;
}

.ys-ai-status:not(:empty)::before {
  content: "●";
  margin-right: 6px;
  font-size: 8px;
}

.ys-ai-status.ys-ai-error {
  color: #a23b32;
}

.ys-ai-composer {
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.9);
}

.ys-ai-composer textarea {
  box-sizing: border-box;
  width: 100%;
  max-height: 130px;
  resize: vertical;
  border: 1px solid rgba(25, 77, 61, 0.2);
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
  color: var(--ai-ink);
  background: #fbfcfa;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.ys-ai-composer textarea:focus {
  border-color: #5c947c;
  box-shadow: 0 0 0 3px rgba(71, 133, 105, 0.12);
}

.ys-ai-composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
}

.ys-ai-send-actions {
  display: flex;
  gap: 7px;
}

.ys-ai-composer-bottom span,
.ys-ai-composer > p {
  color: var(--ai-muted);
  font-size: 10px;
}

.ys-ai-send {
  border: 0;
  border-radius: 10px;
  padding: 9px 18px;
  color: #fff;
  background: var(--ai-green);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.ys-ai-stop {
  border: 1px solid #d6b9b3;
  border-radius: 10px;
  padding: 8px 12px;
  color: #8c392f;
  background: #fff5f3;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

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

.ys-ai-send:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ys-ai-composer > p {
  margin: 7px 0 0;
  text-align: center;
}

@media (max-width: 640px) {
  .ys-ai-launcher {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 11px 15px;
  }

  .ys-ai-panel {
    inset: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
  }

  .ys-ai-header {
    padding-top: calc(18px + env(safe-area-inset-top));
  }

  .ys-ai-messages {
    padding-inline: 12px;
  }

  .ys-ai-message-user {
    margin-left: 28px;
  }

  .ys-ai-quick {
    padding-inline: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ys-ai-panel,
  .ys-ai-backdrop {
    transition: none;
  }
}
