.blog-agent-launcher,
.blog-agent-panel,
.blog-agent-panel * {
  box-sizing: border-box;
}

.blog-agent-launcher {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 24px;
  color: #fff;
  background-color: var(--blog-agent-accent, #2563eb);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(15, 23, 42, 0.14));
  box-shadow: 0 12px 30px -8px rgba(15, 23, 42, 0.38), 0 2px 6px rgba(15, 23, 42, 0.1);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.blog-agent-launcher svg {
  filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.18));
}

.blog-agent-launcher:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 16px 36px -10px rgba(15, 23, 42, 0.42), 0 3px 8px rgba(15, 23, 42, 0.12);
}

.blog-agent-launcher:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.blog-agent-launcher:focus-visible,
.blog-agent-panel button:focus-visible,
.blog-agent-panel a:focus-visible,
.blog-agent-panel textarea:focus-visible {
  outline: 2px solid var(--blog-agent-accent, #2563eb);
  outline-offset: 2px;
}

.blog-agent-panel {
  position: fixed;
  right: 20px;
  bottom: 158px;
  z-index: 2147483000;
  display: none;
  flex-direction: column;
  width: var(--blog-agent-panel-width, 380px);
  height: var(--blog-agent-panel-height, min(560px, calc(100vh - 190px)));
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px -28px rgba(15, 23, 42, 0.42), 0 10px 30px -18px rgba(15, 23, 42, 0.24);
  color: #0f172a;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
}

.blog-agent-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  height: 3px;
  background: linear-gradient(90deg, var(--blog-agent-accent, #2563eb), transparent 78%);
  pointer-events: none;
}

.blog-agent-panel.blog-agent-open {
  display: flex;
  animation: blog-agent-panel-in 0.18s ease-out;
}

@keyframes blog-agent-panel-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.blog-agent-panel.blog-agent-maximized {
  inset: 0;
  width: auto;
  height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.blog-agent-panel.blog-agent-maximized .blog-agent-resize {
  display: none;
}

.blog-agent-resize {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0.55;
}

.blog-agent-resize::before,
.blog-agent-resize::after {
  content: '';
  position: absolute;
  border-top: 1px solid #94a3b8;
  border-left: 1px solid #94a3b8;
  border-top-left-radius: 2px;
}

.blog-agent-resize::before {
  top: 6px;
  left: 6px;
  width: 9px;
  height: 9px;
}

.blog-agent-resize::after {
  top: 10px;
  left: 10px;
  width: 5px;
  height: 5px;
}

.blog-agent-resize:hover,
.blog-agent-panel.blog-agent-resizing .blog-agent-resize {
  opacity: 1;
}

.blog-agent-panel.blog-agent-resizing,
.blog-agent-panel.blog-agent-resizing * {
  cursor: nwse-resize !important;
  user-select: none;
}

.blog-agent-resize-edge {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 3;
  width: 44px;
  height: 10px;
  transform: translateX(-50%);
  cursor: ns-resize;
  touch-action: none;
}

.blog-agent-resize-edge::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: #cbd5e1;
  transform: translateX(-50%);
  opacity: 0.55;
}

.blog-agent-resize-edge:hover::before {
  opacity: 1;
}

.blog-agent-panel.blog-agent-maximized .blog-agent-resize-edge {
  display: none;
}

.blog-agent-panel.blog-agent-resizing-y,
.blog-agent-panel.blog-agent-resizing-y * {
  cursor: ns-resize !important;
  user-select: none;
}

.blog-agent-header {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px 14px;
  border-bottom: 1px solid #edf1f7;
  background: linear-gradient(180deg, #f9fbff 0%, #ffffff 100%);
  cursor: grab;
}

.blog-agent-panel.blog-agent-moving,
.blog-agent-panel.blog-agent-moving * {
  cursor: grabbing !important;
  user-select: none;
}

.blog-agent-heading {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 34px;
  padding-left: 44px;
}

.blog-agent-heading::before {
  content: 'AI';
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  background-color: var(--blog-agent-accent, #2563eb);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(15, 23, 42, 0.18));
  box-shadow: 0 6px 14px -6px rgba(15, 23, 42, 0.5);
}

.blog-agent-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  color: #0f172a;
}

.blog-agent-subtitle {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  color: #64748b;
}

.blog-agent-actions {
  display: flex;
  flex: none;
  gap: 6px;
}

.blog-agent-close,
.blog-agent-clear,
.blog-agent-maximize {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.blog-agent-clear {
  font-size: 18px;
}

.blog-agent-close:hover,
.blog-agent-clear:hover,
.blog-agent-maximize:hover {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #0f172a;
}

.blog-agent-clear:disabled {
  opacity: 0.35;
  cursor: default;
}

.blog-agent-maximize svg {
  display: block;
  width: 18px;
  height: 18px;
}

.blog-agent-panel.blog-agent-maximized .blog-agent-maximize {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #0f172a;
}

.blog-agent-context {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid #edf1f7;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.blog-agent-context-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.blog-agent-context-scope {
  flex: none;
  padding: 3px 8px;
  border: 1px solid #dbe4ef;
  border-radius: 999px;
  background: #fff;
  color: #64748b;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.blog-agent-context-scope[aria-pressed="true"] {
  border-color: var(--blog-agent-accent, #2563eb);
  background: rgba(15, 23, 42, 0.04);
  color: var(--blog-agent-accent, #2563eb);
}

.blog-agent-messages {
  flex: 1 1 0;
  /* 否则内容变多时 min-height:auto 会把输入框挤出面板 */
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #f4f7fb 100%);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.blog-agent-messages::-webkit-scrollbar {
  width: 6px;
}

.blog-agent-messages::-webkit-scrollbar-track {
  background: transparent;
}

.blog-agent-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

.blog-agent-msg {
  display: flex;
  margin-bottom: 14px;
}

.blog-agent-user {
  justify-content: flex-end;
}

.blog-agent-assistant {
  flex-direction: column;
  align-items: flex-start;
}

.blog-agent-bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.blog-agent-assistant .blog-agent-bubble {
  border: 1px solid #e8eef6;
  border-top-left-radius: 5px;
  background: #fff;
  color: #1e293b;
  box-shadow: 0 4px 14px -8px rgba(15, 23, 42, 0.18);
}

.blog-agent-user .blog-agent-bubble {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top-right-radius: 5px;
  background-color: var(--blog-agent-accent, #2563eb);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(15, 23, 42, 0.1));
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.35);
}

.blog-agent-bubble.blog-agent-loading::after {
  content: '…';
  display: inline-block;
  animation: blog-agent-pulse 1.2s infinite;
}

.blog-agent-bubble.blog-agent-error {
  border-color: #fecaca;
  background: #fff5f5;
  color: #b42318;
  box-shadow: none;
}

@keyframes blog-agent-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.blog-agent-sources {
  width: 88%;
  max-width: 88%;
  margin-top: 8px;
  padding: 11px 12px;
  border: 1px solid #e6edf6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 14px -10px rgba(15, 23, 42, 0.2);
}

.blog-agent-sources-title {
  margin-bottom: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #64748b;
  list-style: none;
  cursor: pointer;
}

.blog-agent-sources-title::-webkit-details-marker {
  display: none;
}

.blog-agent-sources-title::after {
  content: '⌄';
  float: right;
  color: #94a3b8;
  transition: transform 0.15s ease;
}

.blog-agent-sources[open] .blog-agent-sources-title {
  margin-bottom: 7px;
}

.blog-agent-sources[open] .blog-agent-sources-title::after {
  transform: rotate(180deg);
}

.blog-agent-source {
  display: flex;
  gap: 8px;
  margin: 0 -6px;
  padding: 7px 6px;
  border-radius: 8px;
  color: #1e293b;
  text-decoration: none;
  transition: background 0.15s ease;
}

.blog-agent-source:hover {
  background: #f6f9fd;
}

.blog-agent-source:hover .blog-agent-source-title {
  color: var(--blog-agent-accent, #2563eb);
}

.blog-agent-source-no {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--blog-agent-accent, #2563eb);
  font-size: 11px;
  line-height: 1;
}

.blog-agent-source-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.blog-agent-source-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.15s ease;
}

.blog-agent-source-heading {
  margin-top: 2px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.blog-agent-source-snippet {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: #7b8798;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.blog-agent-source-active {
  background: #fff7d6 !important;
}

.blog-agent-citation {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blog-agent-accent, #2563eb);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.blog-agent-answer-actions {
  display: flex;
  gap: 8px;
  margin-top: 5px;
}

.blog-agent-copy,
.blog-agent-retry {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.blog-agent-copy:hover,
.blog-agent-retry:hover {
  color: var(--blog-agent-accent, #2563eb);
}

.blog-agent-retry {
  margin-top: 5px;
  color: var(--blog-agent-accent, #2563eb);
  font-weight: 600;
}

.blog-agent-search-link {
  color: var(--blog-agent-accent, #2563eb);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.blog-agent-related {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.blog-agent-related-title,
.blog-agent-followups-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #64748b;
}

.blog-agent-related-link {
  display: inline-block;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 11px;
  line-height: 1.35;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.blog-agent-related-link:hover {
  border-color: var(--blog-agent-accent, #2563eb);
  color: var(--blog-agent-accent, #2563eb);
}

.blog-agent-followups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.blog-agent-followups-title {
  line-height: 25px;
  margin-right: 2px;
}

.blog-agent-followup {
  padding: 5px 11px;
  border: 1px solid var(--blog-agent-accent, #2563eb);
  border-radius: 999px;
  background: transparent;
  color: var(--blog-agent-accent, #2563eb);
  font: inherit;
  font-size: 11.5px;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.blog-agent-followup:hover {
  background: var(--blog-agent-accent, #2563eb);
  color: #fff;
}

.blog-agent-suggestions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
  background: #f4f7fb;
}

.blog-agent-suggestions:empty {
  display: none;
}

.blog-agent-suggestion {
  padding: 7px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  box-shadow: 0 2px 6px -4px rgba(15, 23, 42, 0.15);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.blog-agent-suggestion:hover {
  border-color: var(--blog-agent-accent, #2563eb);
  color: var(--blog-agent-accent, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px -8px rgba(15, 23, 42, 0.3);
}

.blog-agent-form {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 10px;
  border-top: 1px solid #edf1f7;
  background: #fff;
}

.blog-agent-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #dde5ef;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.blog-agent-input::placeholder {
  color: #94a3b8;
}

.blog-agent-input:focus {
  border-color: var(--blog-agent-accent, #2563eb);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
  outline: none;
}

.blog-agent-input:disabled {
  background: #f8fafc;
  color: #94a3b8;
}

.blog-agent-send {
  flex: none;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--blog-agent-accent, #2563eb);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px -10px rgba(15, 23, 42, 0.45);
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.blog-agent-send:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -10px rgba(15, 23, 42, 0.5);
}

.blog-agent-send.blog-agent-send-stop {
  background: #475569;
}

.blog-agent-send:active:not(:disabled) {
  transform: translateY(0);
  filter: brightness(0.98);
}

.blog-agent-send:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.blog-agent-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px 12px;
  background: #fff;
  color: #64748b;
  font-size: 11px;
  line-height: 1.4;
}

.blog-agent-remaining {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.blog-agent-remaining:empty {
  display: none;
}

@media (max-width: 640px) {
  .blog-agent-launcher {
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    height: 44px;
    padding: 0 15px;
    border-radius: 22px;
  }

  .blog-agent-panel {
    inset: 0;
    width: auto;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .blog-agent-resize,
  .blog-agent-resize-edge,
  .blog-agent-maximize {
    display: none;
  }

  .blog-agent-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    cursor: default;
  }

  .blog-agent-footer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .blog-agent-bubble {
    max-width: 92%;
  }

  .blog-agent-sources {
    width: 92%;
    max-width: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-agent-launcher,
  .blog-agent-source,
  .blog-agent-source-title,
  .blog-agent-suggestion,
  .blog-agent-close,
  .blog-agent-maximize,
  .blog-agent-input,
  .blog-agent-send {
    transition: none;
  }

  .blog-agent-panel.blog-agent-open,
  .blog-agent-bubble.blog-agent-loading::after {
    animation: none;
  }
}
