/* 右下角 AI 触发按钮 */
.ai-launcher {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1200;
  transition: opacity 0.2s ease, transform 0.2s ease;
  padding: 0;
}

.ai-launcher:hover {
  transform: scale(1.04);
}

.ai-launcher img {
  width: 28px;
  height: 28px;
  display: block;
}

body.ai-assistant-open .ai-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

/* 右侧 AI 面板 */
.ai-assistant-panel {
  position: fixed;
  top: 0;
  right: 10px;
  bottom: 0;
  width: var(--ai-panel-width);
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid transparent;
  border-radius: 22px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  z-index: 1190;
  backdrop-filter: blur(18px);
}

body.ai-assistant-open .ai-assistant-panel {
  opacity: 1;
  pointer-events: auto;
  border-color: #e5e7eb;
  box-shadow: 0 18px 10px rgba(15, 23, 42, 0.14);
}

.ai-assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #eef2f7;
}

.ai-assistant-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.ai-assistant-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-assistant-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-turn-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ai-assistant-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.ai-assistant-reset {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.ai-assistant-reset svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-assistant-reset:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ai-assistant-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.ai-bubble {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: #334155;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-bubble.assistant {
  align-self: flex-start;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  white-space: normal;
}

.ai-bubble.user {
  align-self: flex-end;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.ai-bubble.error {
  align-self: flex-start;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.ai-bubble.loading {
  color: #64748b;
}

.ai-loading-dots {
  display: inline-block;
  min-width: 24px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.ai-bubble > :first-child {
  margin-top: 0;
}

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

.ai-bubble p {
  margin: 0 0 10px;
}

.ai-bubble strong {
  font-weight: 800;
  color: #111827;
}

.ai-bubble a {
  color: #1a73e8;
  text-decoration: none;
}

.ai-bubble a:hover {
  text-decoration: underline;
}

.ai-bubble ol,
.ai-bubble ul {
  margin: 0 0 10px;
  padding-left: 22px;
}

.ai-bubble li {
  margin: 4px 0;
}

.ai-bubble code:not(pre code) {
  display: inline;
  padding: 0 6px;
  border-radius: 6px;
  background: #eef2f7;
  border: 1px solid #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  white-space: normal;
}

.ai-md-code-group {
  display: block;
  margin: 8px 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.ai-md-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: normal;
  box-sizing: border-box;
}

.ai-md-code-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.ai-md-code-lang {
  font-size: 13px;
  color: #9ca3af;
  padding: 6px;
  line-height: 1;
  white-space: nowrap;
}

.ai-md-code-copy {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  padding: 6px;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  color: #9ca3af;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: none;
  outline: none;
}

.ai-md-code-copy:hover {
  color: #3b82f6;
  background: #f1f5f9;
}

.ai-md-code-copy svg {
  width: 18px;
  height: 18px;
}

.ai-md-pre {
  margin: 0;
  padding: 12px 14px;
  background: #ffffff;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: pre;
  box-sizing: border-box;
  max-width: 100%;
}

.ai-md-pre code {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  box-sizing: border-box;
}

.ai-assistant-composer {
  padding: 16px;
  border-top: 1px solid #eef2f7;
  background: #ffffff;
}

.ai-assistant-form {
  position: relative;
  display: block;
}

.ai-assistant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.ai-assistant-quick-action {
  border: 1px solid #dbe3ec;
  border-radius: 999px;
  padding: 8px 12px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ai-assistant-quick-action:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.ai-assistant-quick-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-assistant-input {
  width: 100%;
  min-height: 56px;
  max-height: 220px;
  resize: none;
  border: 1px solid #dbe3ec;
  border-radius: 14px;
  padding: 14px 72px 14px 14px;
  background: #f8fafc;
  color: #111827;
  outline: none;
  box-sizing: border-box;
  line-height: 1.6;
  overflow-y: hidden;
}

.ai-assistant-input:focus {
  border-color: #93c5fd;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

.ai-assistant-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ai-assistant-send {
  position: absolute;
  right: 28px;
  bottom: 10px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: #d1d5db;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.ai-assistant-send svg {
  width: 24px;
  height: 24px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-assistant-send.is-active:hover {
  transform: translateY(-1px);
  background: #111827;
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.18);
}

.ai-assistant-send:disabled {
  cursor: not-allowed;
  opacity: 1;
  transform: none;
  background: #d1d5db;
  box-shadow: none;
}

.ai-assistant-send.is-active {
  background: #111827;
}

.ai-assistant-note {
  margin-top: 10px;
  font-size: 12px;
  color: #94a3b8;
}

.ai-assistant-note.is-error {
  color: #b91c1c;
}
