.sba-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 25;
  color: #1f1b16;
  font-family: "Microsoft YaHei", system-ui, sans-serif;
}

.sba-root,
.sba-root * {
  box-sizing: border-box;
}

.sba-launcher {
  width: 52px;
  height: 52px;
  margin-left: auto;
  padding: 0;
  border: 1px solid #0b5b52;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #0d7165;
  box-shadow: 0 8px 24px rgba(20, 42, 38, .18);
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease;
}

.sba-launcher:hover {
  background: #095e54;
}

.sba-launcher:active {
  transform: scale(.97);
}

.sba-launcher:focus-visible,
.sba-panel button:focus-visible,
.sba-panel textarea:focus-visible,
.sba-panel a:focus-visible {
  outline: 2px solid #0d7165;
  outline-offset: 2px;
}

.sba-launcher svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sba-launcher-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid #fff;
  border-radius: 9px;
  display: none;
  place-items: center;
  color: #fff;
  background: #b45309;
  font: 11px/1 "SFMono-Regular", Consolas, monospace;
}

.sba-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(392px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 104px));
  border: 1px solid #d8d2c7;
  border-radius: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #1f1b16;
  background: #fffdf8;
  box-shadow: 0 18px 48px rgba(16, 30, 50, .16);
  animation: sba-enter 180ms cubic-bezier(.22, 1, .36, 1) both;
}

.sba-config-view {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 16px;
  overflow: auto;
  background: #fffdf8;
}

.sba-config-view[hidden] {
  display: none;
}

.sba-config-head {
  min-height: 48px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sba-config-head h3 {
  margin: 0;
  color: #1f1b16;
  font-size: 17px;
  font-weight: 500;
  line-height: 24px;
}

.sba-config-head p {
  margin: 4px 0 0;
  color: #7b7266;
  font-size: 11px;
  line-height: 18px;
}

.sba-config-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.sba-config-field {
  display: grid;
  gap: 6px;
}

.sba-config-field span {
  color: #5e554a;
  font-size: 11px;
  line-height: 16px;
}

.sba-config-field input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #cec8bc;
  border-radius: 8px;
  color: #1f1b16;
  background: #fff;
  font: 12px/18px "Microsoft YaHei", system-ui, sans-serif;
}

.sba-config-field input:disabled {
  color: #8a847a;
  background: #f2efe9;
}

.sba-config-key {
  -webkit-text-security: disc;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.sba-config-help {
  margin: 0;
  color: #7b7266;
  font-size: 11px;
  line-height: 18px;
}

.sba-config-error {
  min-height: 18px;
  margin: 0;
  color: #b91c1c;
  font-size: 11px;
  line-height: 18px;
}

.sba-config-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sba-config-actions button {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font: 12px/1 "Microsoft YaHei", system-ui, sans-serif;
  cursor: pointer;
}

.sba-config-cancel {
  border: 1px solid #d9d3c8;
  color: #5e554a;
  background: #fff;
}

.sba-config-save {
  border: 1px solid #0b5b52;
  color: #fff;
  background: #0d7165;
}

.sba-config-save:disabled {
  opacity: .58;
  cursor: wait;
}

.sba-panel[hidden],
.sba-root[hidden] {
  display: none;
}

.sba-head {
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid #e6e1d7;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: #1f1b16;
  background: #fffdf8;
}

.sba-head-copy {
  min-width: 0;
}

.sba-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sba-clear {
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #7b7266;
  background: transparent;
  font: 11px/1 "Microsoft YaHei", system-ui, sans-serif;
  cursor: pointer;
}

.sba-clear:hover {
  border-color: #ded8cd;
  color: #1f1b16;
  background: #f6f3ed;
}

.sba-config-trigger {
  height: 32px;
  padding: 0 8px;
  border: 1px solid #c8d8d3;
  border-radius: 8px;
  color: #0d655c;
  background: #f3f8f5;
  font: 11px/1 "Microsoft YaHei", system-ui, sans-serif;
  cursor: pointer;
}

.sba-config-trigger:hover {
  border-color: #9fbdb5;
  background: #eaf4f0;
}

.sba-config-trigger[hidden] {
  display: none;
}

.sba-kicker {
  display: block;
  margin-bottom: 4px;
  color: #0d7165;
  font-size: 11px;
  line-height: 16px;
}

.sba-title {
  margin: 0;
  color: #1f1b16;
  font-size: 17px;
  font-weight: 500;
  line-height: 22px;
}

.sba-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #7b7266;
  background: transparent;
  cursor: pointer;
}

.sba-close:hover {
  border-color: #ded8cd;
  color: #1f1b16;
  background: #f6f3ed;
}

.sba-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.sba-scope {
  min-height: 38px;
  padding: 8px 16px;
  border-bottom: 1px solid #ece7dc;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5e554a;
  background: #f7f5ef;
  font-size: 11px;
  line-height: 18px;
}

.sba-scope-mark {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #0d7165;
}

.sba-thread {
  min-height: 0;
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.sba-empty {
  padding: 8px 0;
}

.sba-empty h3 {
  margin: 0;
  color: #1f1b16;
  font-size: 16px;
  font-weight: 500;
  line-height: 22px;
}

.sba-empty p {
  margin: 6px 0 14px;
  color: #6f665b;
  font-size: 12px;
  line-height: 19px;
}

.sba-suggestions {
  display: grid;
  gap: 8px;
}

.sba-suggestion {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #ddd8ce;
  border-radius: 9px;
  color: #332e28;
  background: #faf8f3;
  font: 12px/19px "Microsoft YaHei", system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.sba-suggestion:hover {
  border-color: #aebdb7;
  background: #f3f8f5;
}

.sba-message {
  margin-bottom: 14px;
}

.sba-message-role {
  margin-bottom: 5px;
  color: #7b7266;
  font-size: 11px;
  line-height: 16px;
}

.sba-message.user .sba-message-role {
  text-align: right;
}

.sba-message-body {
  padding: 10px 12px;
  border: 1px solid #e1ddd4;
  border-radius: 10px;
  color: #332e28;
  background: #fff;
  font-size: 12px;
  line-height: 19px;
}

.sba-message.user .sba-message-body {
  border-color: #c7d7d1;
  background: #eef6f2;
}

.sba-message-body p {
  margin: 0 0 8px;
}

.sba-message-body p:last-child {
  margin-bottom: 0;
}

.sba-message-body strong {
  color: #1f1b16;
  font-weight: 600;
}

.sba-sources {
  margin-top: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.sba-sources > span {
  color: #7b7266;
  font-size: 11px;
}

.sba-source {
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #d9ded8;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  color: #1f5c54;
  background: #f8faf8;
  font: 11px/18px "Microsoft YaHei", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.sba-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sba-action {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #0b5b52;
  border-radius: 7px;
  color: #fff;
  background: #0d7165;
  font: 11px/18px "Microsoft YaHei", system-ui, sans-serif;
  cursor: pointer;
}

.sba-action:hover {
  background: #095e54;
}

.sba-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7b7266;
}

.sba-loading i {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: #0d7165;
  animation: sba-wait 1.1s ease-in-out infinite;
}

.sba-composer {
  padding: 12px;
  border-top: 1px solid #e6e1d7;
  background: #fcfaf5;
}

.sba-runtime {
  min-height: 18px;
  margin-bottom: 6px;
  color: #7b7266;
  font-size: 11px;
  line-height: 18px;
}

.sba-runtime.warn {
  color: #8a5d00;
}

.sba-input {
  width: 100%;
  min-height: 48px;
  max-height: 116px;
  padding: 9px 10px;
  border: 1px solid #cec8bc;
  border-radius: 9px;
  resize: none;
  color: #1f1b16;
  background: #fff;
  font: 12px/19px "Microsoft YaHei", system-ui, sans-serif;
}

.sba-input::placeholder {
  color: #8a847a;
}

.sba-composer-foot {
  min-height: 30px;
  margin-top: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sba-usage {
  color: #7b7266;
  font: 10px/16px "SFMono-Regular", Consolas, monospace;
}

.sba-send {
  min-width: 64px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #0b5b52;
  border-radius: 8px;
  color: #fff;
  background: #0d7165;
  font: 12px/1 "Microsoft YaHei", system-ui, sans-serif;
  cursor: pointer;
}

.sba-send:hover {
  background: #095e54;
}

.sba-send:disabled,
.sba-input:disabled {
  cursor: not-allowed;
  opacity: .58;
}

@keyframes sba-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sba-wait {
  0%, 100% { opacity: .35; transform: scaleX(.55); transform-origin: left; }
  50% { opacity: 1; transform: scaleX(1); transform-origin: left; }
}

@media (max-width: 640px) {
  .sba-root {
    right: 12px;
    bottom: 12px;
  }

  .sba-panel {
    width: calc(100vw - 24px);
    height: min(72vh, 620px);
    bottom: 64px;
  }
}
