/* ══ ARTICLE CHAT ══ */

.ac-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ac-article-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.ac-article-bar input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--mono);
  background: var(--bg-card);
  color: var(--text-primary);
}

.ac-article-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--neon-glow-soft);
}

.ac-article-bar button {
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ac-article-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 16px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
}

.ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ac-messages::-webkit-scrollbar {
  width: 6px;
}

.ac-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ac-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.ac-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.ac-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}

:root[data-theme="neon-dark"] .ac-msg-user,
:root[data-theme="neon-light"] .ac-msg-user {
  color: #000;
}

.ac-msg-assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
}

.ac-msg-assistant .ac-msg-text {
  overflow-wrap: break-word;
}

.ac-msg-assistant .ac-msg-text p {
  margin: 0 0 8px;
}

.ac-msg-assistant .ac-msg-text p:last-child {
  margin-bottom: 0;
}

.ac-msg-assistant .ac-msg-text code {
  background: var(--bg-secondary);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12px;
}

.ac-msg-assistant .ac-msg-text pre {
  background: var(--bg-secondary);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.ac-msg-assistant .ac-msg-text ul,
.ac-msg-assistant .ac-msg-text ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ac-msg-role {
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
  opacity: 0.6;
}

.ac-msg-user .ac-msg-role {
  color: rgba(255, 255, 255, 0.7);
}

.ac-msg-assistant .ac-msg-role {
  color: var(--accent);
}

.ac-msg-summary {
  border-left: 2px solid var(--accent);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.ac-msg-summary .ac-msg-role {
  opacity: 0.7;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.ac-msg.ac-loading .ac-dots span {
  animation: ac-dot-blink 1.4s infinite both;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
}

.ac-msg.ac-loading .ac-dots span:nth-child(2) { animation-delay: 0.2s; }
.ac-msg.ac-loading .ac-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ac-dot-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.ac-msg-links {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ac-link {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}

.ac-link:hover {
  border-color: var(--accent);
  box-shadow: var(--neon-glow-soft);
  background: var(--bg-secondary);
}

.ac-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.ac-input-bar textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
}

.ac-input-bar textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--neon-glow-soft);
}

.ac-input-bar textarea::placeholder {
  color: var(--text-muted);
}

.ac-input-bar button {
  padding: 8px 16px;
}

.ac-clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 4px;
  padding: 6px 10px;
  white-space: nowrap;
}

.ac-clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#chatPanel.active ~ * .qc-btn,
body:has(#chatPanel.active) .qc-btn {
  display: none;
}

.ac-msg-assistant .ac-msg-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: opacity 0.12s;
}
.ac-msg-assistant .ac-msg-text a:hover { opacity: 0.75; }

/* Inline citation pill — [1] [2] etc. */
.ac-citation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--bg-primary, #0d0d0d) !important;
  background: var(--accent);
  border-radius: 3px;
  padding: 0 4px;
  height: 13px;
  vertical-align: super;
  line-height: 1;
  text-decoration: none !important;
  margin: 0 1px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 6px var(--accent);
  transition: opacity 0.12s;
  cursor: pointer;
}
.ac-citation:hover { opacity: 0.65 !important; }