:root {
  /* Core palette (see header) */
  --ai-ink: #0A1A3A;
  --ai-cobalt: #006DFF;
  --ai-cobalt-deep: #0057CC;
  --ai-cobalt-sky: #2F9BFF;
  --ai-paper: #FFFFFF;
  --ai-fog: #F3F6FA;

  /* Surfaces */
  --ai-bg-deep: var(--ai-fog);
  --ai-bg-primary: var(--ai-paper);
  --ai-bg-surface: #F8FAFC;
  --ai-bg-hover: #EEF3F8;

  /* Borders */
  --ai-border-subtle: rgba(10, 26, 58, 0.06);
  --ai-border-default: rgba(10, 26, 58, 0.10);
  --ai-border-strong: rgba(10, 26, 58, 0.16);

  /* Typography */
  --ai-text-primary: var(--ai-ink);
  --ai-text-secondary: #44546F;
  --ai-text-tertiary: #5B6B85;

  /* Brand — legacy token names remapped onto the cobalt family */
  --ai-accent: var(--ai-cobalt);
  --ai-accent-hover: var(--ai-cobalt-deep);
  --ai-accent-soft: var(--ai-cobalt-sky);
  --ai-accent-dim: rgba(0, 109, 255, 0.08);
  --ai-accent-glow: rgba(0, 109, 255, 0.18);

  /* Functional */
  --ai-success: #007A60;
  --ai-warning: #B45309;
  --ai-warning-dim: rgba(180, 83, 9, 0.10);
  --ai-blue: var(--ai-cobalt-sky);
  --ai-blue-dim: rgba(47, 155, 255, 0.10);
  --ai-danger: #DC2626;
  --ai-danger-dim: rgba(220, 38, 38, 0.08);

  /* Chat bubbles */
  --ai-bubble-bg: #F5F5F7;
  --ai-bubble-border: rgba(10, 26, 58, 0.06);
  --ai-user-bg: var(--ai-ink);

  /* Radii */
  --ai-radius-sm: 8px;
  --ai-radius-md: 14px;
  --ai-radius-xl: 22px;

  /* Shadows */
  --ai-shadow-sm: 0 1px 2px rgba(10, 26, 58, 0.04);
  --ai-shadow-md: 0 4px 12px rgba(10, 26, 58, 0.06);
  --ai-shadow-lg: 0 12px 32px rgba(10, 26, 58, 0.10);

  /* Fonts (overridable by host page) */
  --ai-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ai-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ai-chat-dialog {
  overflow: hidden !important;
  border-radius: var(--ai-radius-sm) !important;
  outline: none;
  box-shadow: var(--ai-shadow-lg) !important;
  border: 1px solid var(--ai-border-default);
  animation: aiDialogRise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  background-color: var(--ai-bg-surface) !important;
}

@keyframes aiDialogRise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* neutralise the default R4S_Dialog table layout */
.ai-chat-dialog>table>tbody>tr:nth-child(2)>td {
  padding: 0 !important;
  overflow: hidden !important;
}

.ai-chat-dialog>table>tbody>tr:last-child {
  display: none !important;
}

/* ── Header (dialog title bar) ─────────────────────────────────────────── */
.ai-chat-dialog .div-dialog-title,
.ai-chat-dialog .div-dialog-V2-title {
  height: auto !important;
  min-height: 64px;
  display: flex !important;
  align-items: center;
  gap: 14px;
  background: var(--ai-bg-primary);
  border-bottom: 1px solid var(--ai-border-subtle);
  cursor: default !important;
  position: relative;
}

.ai-chat-dialog .div-dialog-title-label,
.ai-chat-dialog .div-dialog-V2-title-label {
  position: static !important;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 !important;
  left: auto !important;
  right: auto !important;
}

.ai-chat-dialog .div-dialog-title-label .gwt-Label,
.ai-chat-dialog .div-dialog-V2-title-label .gwt-Label {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.ai-chat-header {
  display: flex;
  width: auto;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.ai-chat-caption-avatar {
  margin: 0.5rem;
}

.ai-chat-caption-avatar,
.ai-chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  /* two-stop cobalt gradient — deep to sky, jewel-tone, not neon */
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--ai-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  position: relative;
  vertical-align: middle;
}

.ai-chat-caption-avatar svg,
.ai-chat-header-avatar svg {
  width: 21px;
  height: 21px;
  color: #fff;
  display: block;
}

.ai-chat-caption-avatar::after,
.ai-chat-header-avatar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ai-success);
  border: 2.5px solid var(--ai-bg-primary);
}

.ai-chat-caption-title,
.ai-chat-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ai-text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  vertical-align: middle;
}

.ai-chat-caption-title {
  display: inline-flex;
  flex-direction: column;
  margin: 0.5rem;
}

.ai-chat-caption-status,
.ai-chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.ai-chat-caption-status-text,
.ai-chat-header-status-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ai-success);
  letter-spacing: 0.02em;
}

.ai-chat-caption-status-text.streaming,
.ai-chat-header-status-text.streaming {
  color: var(--ai-accent);
}

.ai-chat-caption-dot,
.ai-chat-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-success);
  animation: aiPulseDot 2s ease-in-out infinite;
  display: inline-block;
}

.ai-chat-header.streaming .ai-chat-online-dot {
  background: var(--ai-accent);
}

@keyframes aiPulseDot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* close / window icons inside the title bar */
.ai-chat-dialog .div-dialog-title-iconclose,
.ai-chat-dialog .div-dialog-V2-title-iconclose {
  position: static !important;
  top: auto !important;
  right: auto !important;
  width: 34px;
  height: 34px;
  margin: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: var(--ai-radius-sm);
  color: var(--ai-text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.ai-chat-dialog .div-dialog-title-iconclose:hover,
.ai-chat-dialog .div-dialog-V2-title-iconclose:hover {
  background: var(--ai-bg-hover);
  color: var(--ai-text-secondary);
}

/* ============================================================================
CONTENT PANEL  →  .ai-chat-content-panel
============================================================================ */
.ai-chat-content-panel {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  background: var(--ai-bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ai-font);
  color: var(--ai-text-primary);
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ai-chat-content-panel.ai-chat-closing {
  opacity: 0;
  transition: opacity 200ms ease;
}

/* ── Context pill ───────────────────────────────────────────────────────── */
.ai-context-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 9px 13px;
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: var(--ai-radius-sm);
  flex-shrink: 0;
  box-shadow: var(--ai-shadow-sm);
}

.ai-context-pill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 7px;
  background: var(--ai-accent-dim);
  color: var(--ai-accent);
}

.ai-context-pill-icon svg {
  width: 13px;
  height: 13px;
}

.ai-context-pill-id {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ai-text-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.ai-context-pill-subject {
  font-size: 11.5px;
  color: var(--ai-text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ai-context-pill-sep {
  color: var(--ai-border-strong);
  font-size: 11px;
}

/* ============================================================================
HISTORY VIEW  →  .ai-chat-history-view
============================================================================ */
.ai-chat-history-view {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* D7 + D8 — thin cobalt-tinted scrollbar; soft radial wash behind the
   welcome avatar when the transcript is empty */
.ai-chat-history-scroll {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(620px 340px at 50% -120px,
      rgba(0, 109, 255, 0.08) 0%,
      rgba(47, 155, 255, 0.04) 46%,
      rgba(47, 155, 255, 0) 72%),
    var(--ai-bg-surface);
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 109, 255, 0.28) transparent;
}

.ai-chat-history-scroll::-webkit-scrollbar {
  width: 8px;
}

.ai-chat-history-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-history-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 109, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.ai-chat-history-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 109, 255, 0.45);
  background-clip: padding-box;
}

.ai-chat-history {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px 8px;
}

/* framed bot cards provide their own separation — the old hairline divider
   between consecutive AI rows is retired */
.ai-message-ai+.ai-message-ai::before {
  display: none;
}

.ai-system-divider+.ai-message-ai::before,
.ai-action-cards-scroll+.ai-message-ai::before {
  display: none;
}

/* ── Date divider ───────────────────────────────────────────────────────── */
.ai-system-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0 2px;
}

.ai-system-divider::before,
.ai-system-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ai-border-subtle);
}

.ai-system-divider-text {
  font-family: var(--ai-mono);
  font-size: 10px;
  color: var(--ai-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
  font-weight: 500;
}

/* ============================================================================
MESSAGE ROWS
============================================================================ */
.ai-message {
  display: flex;
  flex-direction: column;
  animation: aiMsgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* AI rows: full-width tool framing (Claude / ChatGPT style) */
.ai-message-ai {
  align-self: stretch;
  max-width: none;
  width: 100%;
}

/* User turns: right-aligned bubbles */
.ai-message-user {
  align-self: flex-end;
  max-width: 78%;
  align-items: flex-end;
}

/* ── AI row panel ─────────────────────────────────────────────────────────
   D3 — the bot bubble is now a paper card framed by a hairline gradient
   border (cobalt-deep → cobalt-sky). The user bubble stays solid ink, so
   the two turn types read as deliberately different species. */
.ai-bubble-ai {
  border-radius: var(--ai-radius-md);
  background:
    linear-gradient(var(--ai-paper), var(--ai-paper)) padding-box,
    linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%) border-box;
  box-shadow: var(--ai-shadow-sm);
  padding: 14px 16px 10px;
  color: var(--ai-text-primary);
  word-break: break-word;
  position: relative;
  overflow: hidden; /* clips the D6 sheen sweep */
}

/* D6 — one-time arrival sheen: a fast cobalt glint sweeps the bot card,
   then settles. Pure ::after on an existing class — no markup changes. */
.ai-bubble-ai::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg,
    rgba(47, 155, 255, 0) 32%,
    rgba(47, 155, 255, 0.14) 46%,
    rgba(0, 109, 255, 0.10) 54%,
    rgba(47, 155, 255, 0) 68%);
  transform: translateX(-130%);
  animation: aiSheenSweep 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s 1 both;
}

@keyframes aiSheenSweep {
  from {
    transform: translateX(-130%);
  }
  to {
    transform: translateX(130%);
  }
}

.ai-bubble-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 0 10px;
}

.ai-bubble-label-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
  /* two-stop cobalt gradient — matches the card border tone */
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ai-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ai-bubble-label-avatar svg {
  width: 15px;
  height: 15px;
  color: #fff;
}

.ai-bubble-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.ai-bubble-label-text .ai-label-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ai-text-tertiary);
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.ai-bubble-content {
  padding: 0 0 4px 39px !important;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: -0.005em;
  max-width: 760px;
}

.ai-bubble-content .markdown-body {
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: var(--ai-font);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ai-text-primary);
  text-rendering: optimizeLegibility;
  overflow-wrap: anywhere;
}

.ai-bubble-content .markdown-body p {
  margin: 0 0 8px;
}

.ai-bubble-content .markdown-body p:last-child {
  margin-bottom: 0;
}

.ai-bubble-content .markdown-body strong {
  font-weight: 650;
  color: var(--ai-text-primary);
}

.ai-bubble-content .markdown-body em {
  font-style: italic;
}

.ai-bubble-content .markdown-body h1,
.ai-bubble-content .markdown-body h2,
.ai-bubble-content .markdown-body h3,
.ai-bubble-content .markdown-body h4,
.ai-bubble-content .markdown-body h5,
.ai-bubble-content .markdown-body h6 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ai-text-primary);
  border-bottom: none;
  padding-bottom: 0;
  scroll-margin-top: 24px;
}

.ai-bubble-content .markdown-body h1 {
  font-size: 1.4rem;
}

.ai-bubble-content .markdown-body h2 {
  font-size: 1.25rem;
}

.ai-bubble-content .markdown-body h3 {
  font-size: 1.1rem;
}

.ai-bubble-content .markdown-body h4 {
  font-size: 1rem;
}

.ai-bubble-content .markdown-body h5 {
  font-size: 0.95rem;
}

.ai-bubble-content .markdown-body h6 {
  font-size: 0.85rem;
  color: var(--ai-text-secondary);
}

.ai-bubble-content .markdown-body h1:first-child,
.ai-bubble-content .markdown-body h2:first-child,
.ai-bubble-content .markdown-body h3:first-child {
  margin-top: 0;
}

.ai-bubble-content .markdown-body a {
  color: var(--ai-accent);
  text-decoration: underline;
  text-decoration-color: var(--ai-accent-glow);
  transition: color 0.15s ease;
}

.ai-bubble-content .markdown-body a:hover {
  color: var(--ai-accent-hover);
}

/* lists */
.ai-bubble-content .markdown-body ul,
.ai-bubble-content .markdown-body ol {
  margin: 6px 0;
  padding-left: 22px;
  list-style-position: outside;
}

.ai-bubble-content .markdown-body ul {
  list-style-type: disc;
}

.ai-bubble-content .markdown-body ol {
  list-style-type: decimal;
}

.ai-bubble-content .markdown-body ul ul {
  list-style-type: circle;
}

.ai-bubble-content .markdown-body ul ul ul {
  list-style-type: square;
}

.ai-bubble-content .markdown-body li {
  margin: 3px 0;
  line-height: 1.65;
  color: var(--ai-text-primary);
}

.ai-bubble-content .markdown-body li+li {
  margin-top: 3px;
}

/* inline code */
.ai-bubble-content .markdown-body code,
.ai-bubble-content .markdown-body tt {
  font-family: var(--ai-mono);
  font-size: 0.86em;
  background: var(--ai-accent-dim);
  color: var(--ai-accent-hover);
  border-radius: 6px;
  padding: 2px 6px;
}

/* fenced code blocks — dark theme, no card chrome */
.ai-bubble-content .markdown-body pre,
.ai-bubble-content .markdown-body .highlight {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px 14px;
  border-radius: var(--ai-radius-sm);
  border: none;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
  font-family: var(--ai-mono);
  margin: 8px 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none !important; /* neutralise the Apple hover-lift */
}

.ai-bubble-content .markdown-body pre:hover,
.ai-bubble-content .markdown-body .highlight:hover {
  transform: none !important;
  box-shadow: none;
}

.ai-bubble-content .markdown-body pre code,
.ai-bubble-content .markdown-body .highlight pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* blockquote — chat-toned, no heavy card shadow */
.ai-bubble-content .markdown-body blockquote {
  padding: 6px 14px;
  margin: 8px 0;
  border-left: 3px solid var(--ai-accent);
  border-radius: 0 var(--ai-radius-sm) var(--ai-radius-sm) 0;
  background: var(--ai-accent-dim);
  color: var(--ai-text-secondary);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none !important;
}

.ai-bubble-content .markdown-body blockquote:hover {
  transform: none !important;
  box-shadow: none;
}

/* tables — flat, bordered, no glass */
.ai-bubble-content .markdown-body table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 8px 0;
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--ai-border-default);
  border-radius: var(--ai-radius-sm);
  overflow: hidden;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.ai-bubble-content .markdown-body th,
.ai-bubble-content .markdown-body td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--ai-border-subtle);
  border-radius: 0;
}

.ai-bubble-content .markdown-body th {
  font-weight: 600;
  background: var(--ai-bg-surface);
  color: var(--ai-text-primary);
}

.ai-bubble-content .markdown-body table tr:nth-child(2n) {
  background: var(--ai-bg-surface);
}

.ai-bubble-content .markdown-body table tr:hover {
  background: var(--ai-bg-hover);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* hr */
.ai-bubble-content .markdown-body hr {
  border: none;
  height: 1px;
  background: var(--ai-border-subtle);
  margin: 14px 0;
}

/* inline images */
.ai-bubble-content .markdown-body img {
  max-width: 100%;
  border-radius: var(--ai-radius-sm);
  margin: 8px 0;
  display: block;
}

/* kbd */
.ai-bubble-content .markdown-body kbd {
  display: inline-block;
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1;
  font-family: var(--ai-mono);
  color: var(--ai-text-secondary);
  background: var(--ai-bg-surface);
  border: 1px solid var(--ai-border-default);
  border-radius: 4px;
  box-shadow: inset 0 -1px 0 var(--ai-border-subtle);
}

/* highlight.js syntax tokens (Catppuccin Mocha) */
.ai-bubble-content .markdown-body .hljs-comment,
.ai-bubble-content .markdown-body .hljs-quote {
  color: #7c8499;
}

.ai-bubble-content .markdown-body .hljs-keyword,
.ai-bubble-content .markdown-body .hljs-selector-tag,
.ai-bubble-content .markdown-body .hljs-built_in {
  color: #cba6f7;
}

.ai-bubble-content .markdown-body .hljs-string,
.ai-bubble-content .markdown-body .hljs-attr {
  color: #a6e3a1;
}

.ai-bubble-content .markdown-body .hljs-number,
.ai-bubble-content .markdown-body .hljs-literal {
  color: #fab387;
}

.ai-bubble-content .markdown-body .hljs-title,
.ai-bubble-content .markdown-body .hljs-section,
.ai-bubble-content .markdown-body .hljs-name {
  color: #89b4fa;
}

.ai-bubble-content .markdown-body .hljs-variable,
.ai-bubble-content .markdown-body .hljs-template-variable {
  color: #f38ba8;
}

.ai-bubble-content .markdown-body .hljs-type,
.ai-bubble-content .markdown-body .hljs-class .hljs-title {
  color: #f9e2af;
}

.ai-bubble-content .markdown-body .hljs-tag {
  color: #94e2d5;
}

.ai-bubble-content .markdown-body .hljs-deletion {
  color: #f38ba8;
}

.ai-bubble-content .markdown-body .hljs-addition {
  color: #a6e3a1;
}

.ai-bubble-content .markdown-body .hljs-emphasis {
  font-style: italic;
}

.ai-bubble-content .markdown-body .hljs-strong {
  font-weight: 700;
}

/* inline citation reference */
.ai-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 1px;
  font-size: 9.5px;
  font-weight: 700;
  font-family: var(--ai-mono);
  line-height: 1;
  color: var(--ai-accent);
  background: var(--ai-accent-dim);
  border-radius: 5px;
  vertical-align: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.ai-cite:hover {
  background: var(--ai-accent);
  color: #fff;
  transform: translateY(-1px);
}

/* sources row (optional, hidden until backend provides them) */
.ai-sources {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 0 56px;
  border-top: 1px dashed var(--ai-border-subtle);
  margin-top: 8px;
  max-width: 760px;
}

.ai-sources.visible {
  display: flex;
}

.ai-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 5px;
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: 7px;
  font-size: 11px;
  color: var(--ai-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 240px;
}

.ai-source-chip:hover {
  border-color: var(--ai-accent-glow);
  box-shadow: 0 0 0 1px var(--ai-accent-glow);
}

.ai-source-chip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--ai-accent-dim);
  color: var(--ai-accent);
  font-size: 9px;
  font-weight: 700;
  font-family: var(--ai-mono);
}

.ai-source-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* ── Per-message action bar ─────────────────────────────────────────────── */
.ai-bubble-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 0 0 56px;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: 760px;
}

.ai-message-ai:hover .ai-bubble-actions,
.ai-bubble-actions.always-visible {
  opacity: 1;
}

.ai-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ai-text-tertiary);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.ai-action-btn svg {
  width: 14px;
  height: 14px;
}

.ai-action-btn:hover {
  background: var(--ai-bg-hover);
  color: var(--ai-text-secondary);
}

.ai-action-btn.active.good {
  color: var(--ai-success);
  background: rgba(0, 122, 96, 0.10);
}

.ai-action-btn.active.bad {
  color: var(--ai-danger);
  background: var(--ai-danger-dim);
}

.ai-action-sep {
  width: 1px;
  height: 16px;
  background: var(--ai-border-subtle);
  margin: 0 4px;
}

/* ── Follow-up chips ────────────────────────────────────────────────────── */
.ai-followups {
  display: none;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 0 2px 56px;
  max-width: 760px;
  animation: aiMsgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.ai-followups.visible {
  display: flex;
}

.ai-followup-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 11px;
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ai-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}

.ai-followup-chip svg {
  width: 13px;
  height: 13px;
  color: var(--ai-accent);
  flex-shrink: 0;
}

.ai-followup-chip:hover {
  border-color: var(--ai-accent);
  color: var(--ai-accent);
  background: var(--ai-accent-dim);
  transform: translateY(-1px);
  box-shadow: var(--ai-shadow-sm);
}

/* ── User bubble ──────────────────────────────────────────────────────────
   D3 — stays SOLID ink. No border, no gradient: the weight contrast against
   the hairline-framed bot card is the point. */
.ai-bubble-user {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  word-break: break-word;
  background: var(--ai-user-bg);
  color: #FFFFFF;
  font-weight: 500;
  border-radius: var(--ai-radius-md) var(--ai-radius-md) 4px var(--ai-radius-md);
  box-shadow: 0 4px 14px rgba(10, 26, 58, 0.22);
  position: relative;
  overflow: hidden; /* clips the D6 sheen sweep */
}

/* D6 — arrival sheen for the user turn: a single white glint on navy */
.ai-bubble-user::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg,
    rgba(255, 255, 255, 0) 32%,
    rgba(255, 255, 255, 0.16) 46%,
    rgba(47, 155, 255, 0.12) 54%,
    rgba(255, 255, 255, 0) 68%);
  transform: translateX(-130%);
  animation: aiSheenSweep 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s 1 both;
}

/* ── Timestamps ─────────────────────────────────────────────────────────── */
.ai-bubble-timestamp {
  font-size: 10.5px;
  color: var(--ai-text-tertiary);
  margin-top: 5px;
  padding: 0 4px;
  font-family: var(--ai-mono);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-message-ai .ai-bubble-timestamp {
  justify-content: flex-start;
  padding-left: 56px;
}

.ai-message-user .ai-bubble-timestamp {
  justify-content: flex-end;
}

.ai-tick {
  display: inline-flex;
  align-items: center;
}

.ai-tick svg {
  width: 13px;
  height: 13px;
}

/* ── Typing indicator ─────────────────────────────────────────────────────
   D5 — the dots now travel through the cobalt family (deep → sky) as they
   pulse instead of sitting as flat gray beads. */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0 4px;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--ai-cobalt);
  animation: aiTypingBounce 1.2s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes aiTypingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
    background-color: var(--ai-cobalt-deep);
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
    background-color: var(--ai-cobalt-sky);
  }
}

/* streaming caret */
.ai-caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  vertical-align: -3px;
  background: var(--ai-accent);
  border-radius: 1px;
  animation: aiCaretBlink 1s step-end infinite;
}

@keyframes aiCaretBlink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

/* ── Welcome bubble ─────────────────────────────────────────────────────── */
.ai-bubble-welcome .ai-bubble-label-text .ai-label-sub {
  color: var(--ai-success);
}

/* ============================================================================
ACTION CARDS (capabilities / welcome strip)
============================================================================ */
.ai-action-cards-scroll {
  display: flex;
  flex-direction: row;
  gap: 9px;
  padding: 6px 0 8px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  animation: aiMsgIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both;
  align-self: flex-start;
  scrollbar-width: none;
}

.ai-action-cards-scroll::-webkit-scrollbar {
  display: none;
}

.ai-action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: var(--ai-radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--ai-shadow-sm);
  flex-shrink: 0;
  min-width: 208px;
}

.ai-action-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--ai-accent-dim) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.ai-action-card:hover {
  border-color: var(--ai-accent-glow);
  box-shadow: var(--ai-shadow-md), 0 0 0 1px var(--ai-accent-glow);
  transform: translateY(-1px);
}

.ai-action-card:hover::before {
  opacity: 1;
}

.ai-action-card:active {
  transform: translateX(2px) scale(0.995);
}

/* D4 — outline-free focus: paper gap + cobalt keyline + soft glow,
   all painted with box-shadow */
.ai-action-card:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--ai-bg-primary),
    0 0 0 4px var(--ai-cobalt),
    0 0 0 8px var(--ai-accent-glow),
    var(--ai-shadow-sm);
}

.ai-action-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.ai-action-card-icon svg {
  width: 16px;
  height: 16px;
}

.ai-action-card-icon.ai-action-card-download {
  background: var(--ai-accent-dim);
  color: var(--ai-accent);
}

.ai-action-card-icon.ai-action-card-email {
  background: var(--ai-warning-dim);
  color: var(--ai-warning);
}

.ai-action-card-icon.ai-action-card-ask {
  background: var(--ai-blue-dim);
  color: var(--ai-blue);
}

.ai-action-card-text {
  flex: 1;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.ai-action-card-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ai-text-primary);
  letter-spacing: -0.01em;
}

.ai-action-card-desc {
  font-size: 11px;
  color: var(--ai-text-tertiary);
  margin-top: 2px;
}

.ai-action-card-arrow {
  position: relative;
  z-index: 1;
  color: var(--ai-text-tertiary);
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.ai-action-card-arrow svg {
  width: 14px;
  height: 14px;
  display: block;
}

.ai-action-card:hover .ai-action-card-arrow {
  color: var(--ai-accent);
  transform: translateX(2px);
}

/* ============================================================================
COMPOSER  →  .ai-chat-input-wrapper
============================================================================ */
.ai-chat-input-wrapper {
  flex-shrink: 0;
  background: var(--ai-bg-surface);
  padding: 12px 16px 14px;
  border-top: 1px solid var(--ai-border-subtle);
  position: relative;
}

.ai-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 90%;
  margin: 0 auto;
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: var(--ai-radius-md);
  padding: 5px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ai-chat-input-bar:focus-within {
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 3px var(--ai-accent-dim), 0 0 0 7px rgba(0, 109, 255, 0.05);
}

.ai-input-attach {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--ai-text-tertiary);
  border-radius: var(--ai-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.ai-input-attach svg {
  width: 17px;
  height: 17px;
}

.ai-input-attach:hover {
  background: var(--ai-bg-hover);
  color: var(--ai-text-secondary);
}

.ai-chat-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  border: none !important;
  background: none !important;
  background-color: transparent !important;
  padding: 9px 8px !important;
  margin: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  font-family: var(--ai-font) !important;
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  color: var(--ai-text-primary);
  min-height: 34px;
  resize: none !important;
  max-height: 140px;
  overflow-y: auto;
}

.ai-chat-input::placeholder {
  color: var(--ai-text-tertiary);
  font-weight: 400;
  font-size: 13.5px;
}

.ai-chat-input:focus {
  box-shadow: none !important;
  outline: none !important;
}

/* D2 — the send button speaks in color, not opacity:
   enabled (input has content) = deep→sky cobalt gradient;
   disabled (empty input)      = flat muted fill + color-shifted icon. */
.ai-chat-send {
  width: 36px;
  height: 36px;
  border: none !important;
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%) !important;
  border-radius: var(--ai-radius-sm) !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  box-shadow: var(--ai-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: all 0.18s ease;
  color: #FFFFFF;
}

.ai-chat-send svg {
  width: 16px;
  height: 16px;
  display: block;
}

.ai-chat-send:hover {
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 109, 255, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  filter: saturate(1.06);
}

.ai-chat-send:active {
  transform: translateY(0) scale(0.96);
}

.ai-chat-send:disabled {
  background: var(--ai-bg-hover) !important;
  color: var(--ai-text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

.ai-chat-send:disabled svg {
  opacity: 1;
  color: var(--ai-text-tertiary);
}

/* Stop-generating state — solid ink reads as "brake" against the gradient */
.ai-chat-send.stop {
  background: var(--ai-user-bg) !important;
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(10, 26, 58, 0.25);
  animation: aiStopPulse 1.6s ease-in-out infinite;
}

.ai-chat-send.stop:hover {
  background: #1a2a4f !important;
}

.ai-chat-send.stop svg {
  width: 13px;
  height: 13px;
}

@keyframes aiStopPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(10, 26, 58, 0.30);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(10, 26, 58, 0);
  }
}

.ai-chat-hint {
  padding: 9px 9px 0;
  font-family: var(--ai-mono);
  font-size: 10px;
  color: var(--ai-text-tertiary);
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-hint kbd {
  font-family: var(--ai-mono);
  font-size: 9.5px;
  background: var(--ai-bg-surface);
  border: 1px solid var(--ai-border-default);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--ai-text-secondary);
  font-weight: 500;
}

.ai-chat-hint .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ai-border-strong);
}

/* ============================================================================
SCROLL-TO-BOTTOM FAB
============================================================================ */
.ai-scroll-fab {
  position: absolute;
  bottom: 16px;
  right: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%);
  border: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: var(--ai-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.ai-scroll-fab.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ai-scroll-fab:hover {
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt) 100%);
  transform: translateY(-1px);
  box-shadow: var(--ai-shadow-lg);
}

.ai-scroll-fab svg {
  width: 18px;
  height: 18px;
}

/* ============================================================================
ERROR BUBBLE
============================================================================ */
.ai-bubble-error {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  font-size: 12.5px;
  font-weight: 500;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.07);
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: var(--ai-radius-sm);
  padding: 9px 12px;
}

/* ============================================================================
TOGGLE FAB  →  .ai-fab-button
D1 — the signature idle→active moment:
  closed / idle = SOLID FLAT cobalt, one quiet shadow, nothing else.
  open / active = deep→sky 2-stop gradient + soft outer glow ring.
The open state is keyed to the standard aria-expanded="true" toggle
attribute (no new class needed); :active renders the same treatment as a
press preview so the transition is always visible.
============================================================================ */
.ai-fab-button {
  width: 56px !important;
  height: 56px !important;
  /* squircle — rounded square, not a circle */
  border-radius: 18px !important;
  border: none;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  outline: none;
  font-size: 22px !important;
  /* the RHDImagesV6 font glyph */
  color: #FFFFFF !important;
  /* idle: solid flat cobalt — quiet, minimal, confident */
  background: var(--ai-cobalt) !important;
  box-shadow: 0 1px 2px rgba(10, 26, 58, 0.12);
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease,
    background-color 0.25s ease;
  z-index: 1;
}

.ai-fab-button:hover {
  transform: translateY(-2px);
  background: var(--ai-cobalt) !important;
  box-shadow:
    0 4px 12px rgba(0, 109, 255, 0.28),
    0 1px 3px rgba(10, 26, 58, 0.10);
}

.ai-fab-button:active {
  transform: scale(0.94);
  /* press preview of the open state */
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%) !important;
  box-shadow:
    0 0 0 4px var(--ai-accent-glow),
    0 2px 8px rgba(0, 109, 255, 0.24);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.ai-fab-button[aria-expanded="true"] {
  background: linear-gradient(135deg, var(--ai-cobalt-deep) 0%, var(--ai-cobalt-sky) 100%) !important;
  box-shadow:
    0 0 0 4px var(--ai-accent-glow),
    0 0 20px rgba(0, 109, 255, 0.35),
    0 6px 16px rgba(10, 26, 58, 0.14);
}

.ai-fab-button[aria-expanded="true"]:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 4px var(--ai-accent-glow),
    0 0 26px rgba(0, 109, 255, 0.42),
    0 8px 20px rgba(10, 26, 58, 0.16);
}

/* D4 — keyboard focus, outline-free: paper gap + cobalt keyline + halo */
.ai-fab-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--ai-bg-primary),
    0 0 0 4px var(--ai-cobalt),
    0 0 0 8px var(--ai-accent-glow),
    0 4px 14px rgba(0, 109, 255, 0.22);
}

.ai-chat-dialog-content {
  height: 90%;
}

/* ── Tool calls ─────────────────────────────────────────────────────────── */
.ai-tool-calls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 8px 56px;
  max-width: 760px;
  animation: aiMsgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* a single collapsible tool-call card — chip aesthetic: white surface,
tonal border, accent tint on hover */
.ai-tool {
  background: var(--ai-bg-primary);
  border: 1px solid var(--ai-border-default);
  border-radius: var(--ai-radius-sm);
  box-shadow: var(--ai-shadow-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-tool:hover {
  border-color: var(--ai-accent-glow);
  box-shadow: var(--ai-shadow-sm), 0 0 0 1px var(--ai-accent-glow);
}

/* header row — click to toggle */
.ai-tool-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.ai-tool-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--ai-accent-dim);
  color: var(--ai-accent);
}

.ai-tool-icon svg {
  width: 12px;
  height: 12px;
}

.ai-tool.running .ai-tool-icon {
  background: rgba(180, 83, 9, 0.10);
  color: var(--ai-warning);
  animation: aiToolSpin 1.4s linear infinite;
}

.ai-tool.ok .ai-tool-icon {
  background: rgba(0, 122, 96, 0.10);
  color: var(--ai-success);
}

.ai-tool.error .ai-tool-icon {
  background: var(--ai-danger-dim);
  color: var(--ai-danger);
}

@keyframes aiToolSpin {
  to {
    transform: rotate(15deg);
  }
}

.ai-tool-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ai-text-secondary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* status badge — monospace chip on the right */
.ai-tool-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ai-mono);
  flex-shrink: 0;
  background: var(--ai-bg-surface);
  color: var(--ai-text-tertiary);
}

.ai-tool.running .ai-tool-badge {
  background: rgba(180, 83, 9, 0.12);
  color: var(--ai-warning);
}

.ai-tool.ok .ai-tool-badge {
  background: rgba(0, 122, 96, 0.12);
  color: var(--ai-success);
}

.ai-tool.error .ai-tool-badge {
  background: var(--ai-danger-dim);
  color: var(--ai-danger);
}

/* expandable body */
.ai-tool-body {
  display: none;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--ai-border-subtle);
  background: var(--ai-bg-surface);
}

.ai-tool.open .ai-tool-body {
  display: flex;
}

/* a labeled JSON section (input / output / error) */
.ai-tool-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
}

.ai-tool-section+.ai-tool-section {
  border-top: 1px solid var(--ai-border-subtle);
}

.ai-tool-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ai-text-tertiary);
  font-family: var(--ai-mono);
}

.ai-tool-section-value pre {
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none !important;
  font-size: 11.5px;
  line-height: 1.5;
  font-family: var(--ai-mono);
  color: var(--ai-text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-tool-section-value pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-family: inherit;
}

.ai-tool.error .ai-tool-section:last-child .ai-tool-section-value pre {
  color: var(--ai-danger);
}

/* markdown rendered inside tool-call sections (R4S_Markdown → .markdown-body).
Scoped to .ai-tool-section (the section parent) because after the lazy
markdown swap the widget carries "markdown-body" on the same element as
"ai-tool-section-value", so a descendant combinator wouldn't match.
Uses the same dark code-block treatment as the main chat (Catppuccin Mocha)
so JSON output is readable and visually consistent. */
.ai-tool-section .markdown-body {
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: var(--ai-mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: #cdd6f4;
}

.ai-tool-section .markdown-body pre,
.ai-tool-section .markdown-body .highlight {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 10px 12px;
  margin: 0;
  border: none;
  border-radius: 6px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none !important;
  overflow-x: auto;
  font-size: inherit;
  line-height: inherit;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-tool-section .markdown-body pre:hover,
.ai-tool-section .markdown-body .highlight:hover {
  transform: none !important;
  box-shadow: none;
}

.ai-tool-section .markdown-body pre code,
.ai-tool-section .markdown-body .highlight pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-family: inherit;
}

/* highlight.js JSON tokens — Catppuccin Mocha palette (same as main chat) */
.ai-tool-section .markdown-body .hljs-comment,
.ai-tool-section .markdown-body .hljs-quote {
  color: #7c8499;
  font-style: italic;
}

.ai-tool-section .markdown-body .hljs-keyword,
.ai-tool-section .markdown-body .hljs-selector-tag,
.ai-tool-section .markdown-body .hljs-built_in,
.ai-tool-section .markdown-body .hljs-type {
  color: #cba6f7;
}

.ai-tool-section .markdown-body .hljs-attr,
.ai-tool-section .markdown-body .hljs-name,
.ai-tool-section .markdown-body .hljs-property {
  color: #89b4fa;
}

.ai-tool-section .markdown-body .hljs-string,
.ai-tool-section .markdown-body .hljs-addition {
  color: #a6e3a1;
}

.ai-tool-section .markdown-body .hljs-number,
.ai-tool-section .markdown-body .hljs-literal {
  color: #fab387;
}

.ai-tool-section .markdown-body .hljs-variable,
.ai-tool-section .markdown-body .hljs-template-variable {
  color: #f38ba8;
}

.ai-tool-section .markdown-body .hljs-title,
.ai-tool-section .markdown-body .hljs-section {
  color: #f9e2af;
}

.ai-tool-section .markdown-body .hljs-tag {
  color: #94e2d5;
}

.ai-tool-section .markdown-body .hljs-punctuation {
  color: #cdd6f4;
}

.ai-tool-section .markdown-body .hljs-deletion {
  color: #f38ba8;
}

.ai-tool-section .markdown-body .hljs-emphasis {
  font-style: italic;
}

.ai-tool-section .markdown-body .hljs-strong {
  font-weight: 700;
}

/* ============================================================================
D4 — FOCUS-VISIBLE across every interactive element, outline-free.
No outline property anywhere: the indicator is a three-layer box-shadow —
paper gap keyline, tight cobalt ring, soft diffuse glow. Still a clear,
WCAG-visible two-tone signal, just softer than a browser outline.
============================================================================ */
.ai-action-btn:focus-visible,
.ai-input-attach:focus-visible,
.ai-chat-send:focus-visible,
.ai-scroll-fab:focus-visible,
.ai-followup-chip:focus-visible,
.ai-source-chip:focus-visible,
.ai-cite:focus-visible,
.ai-tool-head:focus-visible,
.ai-chat-dialog .div-dialog-title-iconclose:focus-visible,
.ai-chat-dialog .div-dialog-V2-title-iconclose:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--ai-bg-primary),
    0 0 0 4px var(--ai-cobalt),
    0 0 0 8px var(--ai-accent-glow);
}

.ai-bubble-content .markdown-body a:focus-visible {
  outline: none;
  border-radius: 3px;
  box-shadow:
    0 0 0 2px var(--ai-bg-primary),
    0 0 0 4px var(--ai-cobalt),
    0 0 0 8px var(--ai-accent-glow);
  color: var(--ai-accent-hover);
}

/* ============================================================================
REDUCED MOTION — the sheen sweep (D6) and the gradient color-shift on the
typing dots (D5) are removed entirely; everything falls back to a static,
fully legible state.
============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ai-bubble-ai::after,
  .ai-bubble-user::after {
    display: none;
  }

  .ai-typing-dot {
    background-color: var(--ai-cobalt);
    opacity: 0.8;
  }
}