.sub2api-ai-widget,
.sub2api-ai-widget * {
  box-sizing: border-box;
}

.sub2api-ai-widget {
  --ai-bg: #ffffff;
  --ai-surface: #f7f8fa;
  --ai-text: #171a1f;
  --ai-muted: #667085;
  --ai-border: rgba(17, 24, 39, 0.14);
  --ai-primary: #2563eb;
  --ai-primary-text: #ffffff;
  --ai-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ai-text);
}

.sub2api-ai-widget[data-theme="dark"] {
  --ai-bg: #111827;
  --ai-surface: #1f2937;
  --ai-text: #f9fafb;
  --ai-muted: #a5b4c7;
  --ai-border: rgba(255, 255, 255, 0.15);
  --ai-primary: #60a5fa;
  --ai-primary-text: #08111f;
  --ai-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.sub2api-ai-toggle {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--ai-primary);
  color: var(--ai-primary-text);
  box-shadow: var(--ai-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sub2api-ai-toggle svg,
.sub2api-ai-icon-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sub2api-ai-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 96px));
  min-height: 420px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  box-shadow: var(--ai-shadow);
  overflow: hidden;
  display: none;
  grid-template-rows: auto 1fr auto;
}

.sub2api-ai-widget[data-open="true"] .sub2api-ai-panel {
  display: grid;
}

.sub2api-ai-head {
  height: 52px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--ai-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sub2api-ai-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 14px;
}

.sub2api-ai-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
  flex: 0 0 auto;
}

.sub2api-ai-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sub2api-ai-icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ai-muted);
  cursor: pointer;
}

.sub2api-ai-icon-btn:hover {
  background: var(--ai-surface);
  color: var(--ai-text);
}

.sub2api-ai-body {
  overflow-y: auto;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.05), transparent 160px),
    var(--ai-bg);
}

.sub2api-ai-msg {
  display: flex;
  margin: 0 0 10px;
}

.sub2api-ai-msg[data-role="user"] {
  justify-content: flex-end;
}

.sub2api-ai-bubble {
  max-width: 84%;
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  padding: 9px 10px;
  line-height: 1.45;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--ai-surface);
}

.sub2api-ai-msg[data-role="user"] .sub2api-ai-bubble {
  background: var(--ai-primary);
  color: var(--ai-primary-text);
  border-color: transparent;
}

.sub2api-ai-foot {
  border-top: 1px solid var(--ai-border);
  padding: 10px;
  background: var(--ai-bg);
}

.sub2api-ai-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.sub2api-ai-input {
  min-height: 42px;
  max-height: 110px;
  resize: none;
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--ai-surface);
  color: var(--ai-text);
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  outline: none;
}

.sub2api-ai-input:focus {
  border-color: var(--ai-primary);
}

.sub2api-ai-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ai-primary);
  color: var(--ai-primary-text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sub2api-ai-send:disabled,
.sub2api-ai-input:disabled {
  opacity: 0.55;
  cursor: wait;
}

.sub2api-ai-hint {
  min-height: 18px;
  margin-top: 7px;
  color: var(--ai-muted);
  font-size: 12px;
}

@media (max-width: 520px) {
  .sub2api-ai-widget {
    right: 14px;
    bottom: 14px;
  }

  .sub2api-ai-panel {
    bottom: 62px;
    width: calc(100vw - 28px);
    height: min(560px, calc(100vh - 88px));
  }
}
