/* ============================================
   AI ASSISTANT SIDEBAR
   ============================================ */

#aa-docs-assistant-sidebar {
  position: fixed;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--color__base-white);
  border-left: 1px solid var(--color__base-gray-light2);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.2s ease;
}

#aa-docs-assistant-sidebar.is-open {
  transform: translateX(0);
}

.aa-sidebar__resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: ew-resize;
  transition: background 0.15s;
  z-index: 1;
}

.aa-sidebar__resize:hover,
.aa-sidebar__resize.is-resizing {
  background: rgba(2, 128, 254, 0.35);
}

.aa-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px 20px;
  border-bottom: 1px solid var(--color__base-gray-light2);
  flex-shrink: 0;
  background: var(--color__base-white);
}

html[data-theme="dark"] .aa-sidebar__header {
  background: var(--pst-color-on-background);
}

.aa-sidebar__header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px 2px 0;
  transition: opacity 0.15s ease;
  min-width: 0;
}

.aa-sidebar__header-left:hover {
  opacity: 0.75;
}

.aa-sidebar__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--color__base-black);
  font-size: 14px;
  font-family: var(--font__base-astra);
  min-width: 0;
}

.aa-sidebar__title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aa-sidebar__controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.aa-sidebar__btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--color__base-gray-light2);
  background: transparent;
  color: var(--color__base-gray-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.aa-sidebar__btn:hover {
  background: var(--color__base-gray-light2);
  border-color: var(--color__base-gray);
}

.aa-sidebar__btn.is-active {
  background: rgba(2, 128, 254, 0.1);
  border-color: var(--color__base-blue);
  color: var(--color__base-blue);
}

/* Header icon buttons (history chevron, new, expand, close) use light-theme
   base tokens that don't remap — on the dark header they'd be near-invisible.
   Give them light icons + subtle alpha borders. is-active keeps its blue. */
html[data-theme="dark"] .aa-sidebar__btn {
  color: var(--aa-graphite-900);
  border-color: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .aa-sidebar__btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   CHAT UI — COLOR TOKENS
   ============================================ */

:root {
  --aa-graphite-100: #f9f9fc;
  --aa-graphite-200: #f7f8fa;
  --aa-graphite-300: #f3f4f7;
  --aa-graphite-400: #eff0f4;
  --aa-graphite-500: #dfe0e9;
  --aa-graphite-600: #ced1de;
  --aa-graphite-700: #bec1d3;
  --aa-graphite-800: #7c82a7;
  --aa-graphite-900: #494e6c;
  --aa-graphite-1000: #1d1f2b;
  --aa-neon-400: #f5fbfe;
  --aa-blue-100: #80bffe;
  --aa-blue-200: #3b6df0;
  --aa-blue-500: #0280fe;
  --aa-blue-700: #0057a8;
  --aa-red-50: #f5dcdc;
  --aa-red-100: #f47373;
  --aa-red-200: #a70000;
}

/* ============================================
   DARK THEME — remap the graphite scale
   The scale is hardcoded for a light UI (low tokens = light surfaces, high
   tokens = dark text). Re-map it under the theme's dark mode so every
   token-driven color (bubble text, history items, greeting, chips, code/table
   backgrounds, borders) adapts at once — then patch the few spots that use a
   non-graphite light background.
   ============================================ */

html[data-theme="dark"] {
  --aa-graphite-100: #2a2c39; /* chip / pill / code / table-head surfaces */
  --aa-graphite-200: #30323f; /* code, pre, hover surfaces */
  --aa-graphite-300: #3a3c4a; /* dividers / borders */
  --aa-graphite-400: #44475a;
  --aa-graphite-500: #4f5266;
  --aa-graphite-600: #5b5f75; /* input / dashed borders */
  --aa-graphite-700: #9aa0bd; /* muted text, dots, icons */
  --aa-graphite-800: #b6bbd4;
  --aa-graphite-900: #d7dae8; /* secondary text */
  --aa-graphite-1000: #f2f3f8; /* primary text */
}

/* User bubble keeps a light (neon) background in light mode; on dark give it a
   tinted surface so its now-light text stays readable. */
html[data-theme="dark"] .aa-msg-row[data-role="user"] .aa-msg-bubble {
  background: rgba(2, 128, 254, 0.22);
}

/* Header title uses a non-graphite black token — force it light. */
html[data-theme="dark"] .aa-sidebar__title {
  color: var(--aa-graphite-1000);
}

/* Use subtle light-alpha dividers on dark instead of the light graphite lines. */
html[data-theme="dark"] .aa-msg-bubble th,
html[data-theme="dark"] .aa-msg-bubble td {
  border-color: rgba(255, 255, 255, 0.14);
}

html[data-theme="dark"] .aa-history-item,
html[data-theme="dark"] .aa-history-header,
html[data-theme="dark"] .aa-history-new {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* ============================================
   CHAT ROOT
   ============================================ */

.aa-chat-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: #fff;
  min-height: 0;
}

html[data-theme="dark"] .aa-chat-root {
  background: var(--pst-color-background);
}

.aa-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ============================================
   VIEWPORT & MESSAGES
   ============================================ */

.aa-chat-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.aa-messages {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* One pane per chat; only the active one is shown (inline display toggled in
   JS). Mirrors .aa-messages so rows stack identically inside a pane. */
.aa-chat-pane {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ============================================
   MESSAGE ROWS
   ============================================ */

.aa-msg-row {
  display: flex;
  margin-bottom: 16px;
  width: 100%;
}

.aa-msg-row[data-role="assistant"] {
  justify-content: flex-start;
}

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

.aa-msg-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 88%;
}

.aa-msg-row[data-role="user"] .aa-msg-stack {
  align-items: flex-end;
}

/* ============================================
   BUBBLES
   ============================================ */

.aa-msg-bubble {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--aa-graphite-1000);
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  word-break: break-word;
  overflow-wrap: break-word;
}

.aa-msg-row[data-role="user"] .aa-msg-bubble {
  background: var(--aa-neon-400);
}

.aa-msg-row[data-role="assistant"] .aa-msg-bubble {
  background: transparent;
  padding: 4px 0;
}

/* Markdown inside bubbles */
.aa-msg-bubble p {
  margin: 6px 0;
}

.aa-msg-bubble p:first-child {
  margin-top: 0;
}

.aa-msg-bubble p:last-child {
  margin-bottom: 0;
}

.aa-msg-bubble h1,
.aa-msg-bubble h2,
.aa-msg-bubble h3,
.aa-msg-bubble h4,
.aa-msg-bubble h5,
.aa-msg-bubble h6 {
  margin: 8px 0 4px;
  font-weight: 700;
  color: var(--aa-graphite-1000);
}

.aa-msg-bubble h1 {
  font-size: 1.3em;
}
.aa-msg-bubble h2 {
  font-size: 1.15em;
}
.aa-msg-bubble h3,
.aa-msg-bubble h4,
.aa-msg-bubble h5,
.aa-msg-bubble h6 {
  font-size: 1em;
}

.aa-msg-bubble ul,
.aa-msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.aa-msg-bubble li {
  margin: 3px 0;
}

.aa-msg-bubble pre {
  background: var(--aa-graphite-200);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  overflow-x: auto;
}

.aa-msg-bubble code {
  background: var(--aa-graphite-200);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12.5px;
  font-family: "Courier New", Courier, monospace;
}

.aa-msg-bubble pre code {
  background: none;
  padding: 0;
}

.aa-msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12.5px;
}

.aa-msg-bubble th,
.aa-msg-bubble td {
  border: 1px solid var(--aa-graphite-500);
  padding: 5px 10px;
  text-align: left;
}

.aa-msg-bubble th {
  background: var(--aa-graphite-200);
  font-weight: 600;
}

.aa-msg-bubble hr {
  border: none;
  border-top: 1px solid var(--aa-graphite-400);
  margin: 10px 0;
}

/* ============================================
   SELECTION PILL (inside user message)
   ============================================ */

.aa-msg-selection-pill {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px dashed var(--aa-graphite-600);
  border-radius: 6px;
  color: var(--aa-graphite-900);
  font-style: italic;
  margin-bottom: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

/* ============================================
   ERROR BUBBLE
   ============================================ */

.aa-bubble-error {
  background: var(--aa-red-50) !important;
  border: 1px solid var(--aa-red-100);
  padding: 10px 14px !important;
  border-radius: 8px;
}

.aa-error-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.aa-error-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--aa-red-100);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.aa-error-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.aa-error-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--aa-red-200);
}

.aa-error-detail {
  font-size: 12px;
  color: var(--aa-graphite-900);
  word-break: break-word;
}

.aa-error-retry {
  appearance: none;
  border: 1px solid var(--aa-red-100);
  background: #fff;
  color: var(--aa-red-200);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 4px;
  align-self: flex-start;
  transition: background 0.15s;
}

.aa-error-retry:hover:not(:disabled) {
  background: var(--aa-red-50);
}

.aa-error-retry:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ============================================
   PER-MESSAGE ACTIONS (copy as markdown)
   ============================================ */

.aa-msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.aa-msg-action-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--aa-graphite-800);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.aa-msg-action-btn:hover {
  background: var(--aa-graphite-300);
  color: var(--aa-graphite-1000);
}

.aa-msg-action-btn.is-copied {
  color: var(--aa-blue-500);
}

/* ============================================
   TYPING ANIMATION
   ============================================ */

.aa-typing-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 1.5em;
  padding: 4px 0;
}

.aa-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.aa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aa-graphite-700);
  animation: aa-typing 1.2s infinite both;
  display: inline-block;
}

.aa-dot:nth-child(2) {
  animation-delay: 0.15s;
}
.aa-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes aa-typing {
  0% {
    opacity: 0.25;
    transform: translateY(0);
  }
  25% {
    opacity: 1;
    transform: translateY(-2px);
  }
  50% {
    opacity: 0.25;
    transform: translateY(0);
  }
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .aa-dot {
    animation: none;
    opacity: 0.6;
  }
}

.aa-thinking-phrase {
  font-size: 13px;
  color: var(--aa-graphite-700);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.aa-thinking-phrase.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   GREETING
   ============================================ */

.aa-greeting {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px 8px;
}

.aa-greeting-title {
  font-size: 14px;
  color: var(--aa-graphite-900);
  text-align: center;
  margin-bottom: 16px;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
}

.aa-starter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  justify-content: flex-start;
}

.aa-starter-chip {
  appearance: none;
  border: 1px solid var(--aa-graphite-500);
  background: var(--aa-graphite-100);
  color: var(--aa-graphite-1000);
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.4;
  text-align: left;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  transition: background 0.15s, border-color 0.15s;
}

.aa-starter-chip:hover {
  background: var(--aa-graphite-200);
  border-color: var(--aa-graphite-700);
}

/* ============================================
   COMPOSER
   ============================================ */

.aa-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--aa-graphite-500);
  padding: 10px 12px 8px;
  background: #fff;
}

html[data-theme="dark"] .aa-composer {
  background: var(--pst-color-background);
  border-top-color: rgba(255, 255, 255, 0.1);
}

.aa-composer-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aa-composer-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--aa-graphite-600);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  color: var(--aa-graphite-1000);
  resize: none;
  outline: none;
  box-sizing: border-box;
  line-height: 1.4;
  min-height: 40px;
  max-height: 120px;
  scrollbar-width: none;
  transition: border-color 0.15s;
}

.aa-composer-input::-webkit-scrollbar {
  display: none;
}

.aa-composer-input::placeholder {
  color: var(--aa-graphite-700);
  font-size: 13px;
}

.aa-composer-input:focus {
  border-color: var(--aa-blue-200);
}

html[data-theme="dark"] .aa-composer-input {
  background: var(--pst-color-on-background);
  color: var(--pst-color-text-base);
  border-color: var(--aa-graphite-800);
}

.aa-composer-send {
  width: 100%;
  padding: 12px 24px;
  height: auto;
  min-height: 45px;
  background: var(--aa-blue-500);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  cursor: pointer;
  transition: background 0.15s;
}

.aa-composer-send:hover:not(:disabled) {
  background: #07c;
}

.aa-composer-send:active:not(:disabled) {
  background: var(--aa-blue-700);
}

.aa-composer-send:disabled {
  background: var(--aa-blue-100);
  cursor: not-allowed;
}

.aa-disclaimer {
  font-size: 11px;
  color: var(--aa-graphite-700);
  text-align: center;
  margin-top: 16px;
}

/* ============================================
   CONTEXT ROW (page + selection pills)
   ============================================ */

.aa-context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.aa-selection-hint,
.aa-add-context-btn {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--aa-graphite-600);
  border-radius: 8px;
  color: var(--aa-graphite-700);
}

.aa-add-context-btn {
  cursor: pointer;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  transition: border-color 0.12s, color 0.12s;
}

.aa-add-context-btn:hover {
  border-color: var(--aa-blue-200);
  color: var(--aa-graphite-1000);
}

.aa-context-pill,
.aa-selection-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 6px 3px 9px;
  background: var(--aa-graphite-100);
  border-radius: 8px;
  color: var(--aa-graphite-1000);
  max-width: 100%;
  box-sizing: border-box;
}

.aa-context-pill {
  border: 1px solid var(--aa-graphite-500);
}

.aa-selection-pill {
  border: 1px dashed var(--aa-graphite-600);
}

.aa-context-pill-name,
.aa-selection-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.aa-selection-pill-text {
  font-style: italic;
  color: var(--aa-graphite-900);
}

.aa-context-pill-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--aa-graphite-700);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.12s;
}

.aa-context-pill-remove:hover {
  color: var(--aa-graphite-1000);
}

/* ============================================
   HISTORY PANEL
   ============================================ */

.aa-history-panel {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 260px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--aa-graphite-300);
  box-shadow: 2px 0 16px rgba(29, 31, 43, 0.12);
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

html[data-theme="dark"] .aa-history-panel {
  background: var(--pst-color-background);
}

.aa-history-panel.is-open {
  transform: translateX(0);
}

.aa-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--aa-graphite-300);
  flex-shrink: 0;
}

.aa-history-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--aa-graphite-1000);
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
}

.aa-history-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--aa-graphite-700);
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.aa-history-close:hover {
  background: var(--aa-graphite-200);
  color: var(--aa-graphite-1000);
}

.aa-history-new {
  padding: 10px 16px;
  border-bottom: 1px solid var(--aa-graphite-300);
  flex-shrink: 0;
}

.aa-history-new-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--aa-graphite-400);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--aa-blue-500);
  cursor: pointer;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.aa-history-new-btn:hover {
  background: rgba(2, 128, 254, 0.06);
  border-color: var(--aa-blue-500);
}

.aa-history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}

.aa-history-list::-webkit-scrollbar {
  display: none;
}

.aa-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--aa-graphite-200);
  cursor: pointer;
  transition: background 0.12s;
}

.aa-history-item:last-child {
  border-bottom: none;
}

.aa-history-item:hover {
  background: var(--aa-graphite-200);
}

.aa-history-item:hover .aa-history-item-del {
  opacity: 1;
}

.aa-history-item.is-active {
  background: rgba(2, 128, 254, 0.06);
}

.aa-history-item.is-active .aa-history-item-name {
  color: var(--aa-blue-500);
}

.aa-history-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--aa-graphite-1000);
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
}

.aa-history-item-del {
  flex-shrink: 0;
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--aa-graphite-700);
  padding: 0 4px;
  border-radius: 4px;
  transition: opacity 0.15s, background 0.12s, color 0.12s;
}

.aa-history-item-del:hover {
  background: var(--aa-graphite-400);
  color: var(--aa-graphite-1000);
}

.aa-history-loading,
.aa-history-empty,
.aa-history-error {
  padding: 20px 16px;
  font-size: 13px;
  color: var(--aa-graphite-700);
  text-align: center;
  font-family: var(
    --font__base-astra,
    "PT Astra Fact",
    Verdana,
    Arial,
    sans-serif
  );
}

.aa-history-error p {
  margin: 0 0 8px;
  color: var(--aa-red-200);
}

.aa-history-retry-btn {
  appearance: none;
  border: 1px solid var(--aa-red-100);
  background: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--aa-red-200);
  cursor: pointer;
  transition: background 0.15s;
}

.aa-history-retry-btn:hover {
  background: rgba(244, 115, 115, 0.08);
}

body.aa-sidebar-resizing,
body.aa-sidebar-resizing * {
  cursor: ew-resize !important;
  user-select: none !important;
}

/* Active state: button glows when sidebar is open */
#open-docs-bot-btn[data-active="true"] {
  border-color: var(--color__base-blue) !important;
  box-shadow: 0 0 0 2px rgba(2, 128, 254, 0.25) !important;
}

html[data-theme="dark"] #aa-docs-assistant-sidebar {
  border-left-color: rgba(255, 255, 255, 0.08);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

/* Tablet and mobile: full-screen overlay (navbar collapses at 992px in pydata theme) */
@media (max-width: 992px) {
  #aa-docs-assistant-sidebar {
    width: 100vw !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999;
  }

  #aa-docs-assistant-sidebar .aa-sidebar__resize {
    display: none;
  }

  #aa-docs-assistant-sidebar .aa-sidebar__btn--expand {
    display: none;
  }
}

/* Nav drawer: all 4 icons in a single row, Помощник icon-only */
.bd-sidebar-primary .sidebar-header-items__end {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 16px !important;
  padding: 10px 16px !important;
  border-bottom: 1px solid var(--color__base-gray-light2);
}

.bd-sidebar-primary .navbar-icon-links {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 16px !important;
  padding: 0 !important;
  margin: 0 !important;
  list-style: none;
}

.bd-sidebar-primary .navbar-icon-links li {
  padding: 0 !important;
}

/* Uniform 36×36 for all icons in nav drawer */
.bd-sidebar-primary .sidebar-header-items__end a.pst-navbar-icon {
  width: 36px !important;
  height: 36px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  box-sizing: border-box;
}

.bd-sidebar-primary .sidebar-header-items__end .btn.theme-switch-button {
  width: 36px !important;
  height: 36px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}

/* Помощник button: icon-only with original border/frame styling, 36×36 */
.bd-sidebar-primary #open-docs-bot-btn {
  margin: 0 !important;
  flex-shrink: 0;
  width: 36px !important;
  height: 36px !important;
}

.bd-sidebar-primary #open-docs-bot-btn span {
  display: none !important;
}

.bd-sidebar-primary #open-docs-bot-btn > div {
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* On desktop-small (993–1535px): 2×2 icon grid, text hidden */
@media (min-width: 993px) and (max-width: 1535px) {
  .bd-header .navbar-header-items__end {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    align-items: center;
    justify-items: center;
    width: fit-content;
    margin-left: 8px;
  }

  /* Row 1: icon links (PDF + API) span both columns */
  .bd-header .navbar-header-items__end .navbar-item:first-child {
    grid-column: 1 / span 2;
    grid-row: 1;
    display: flex;
    justify-content: space-around;
    width: 100%;
    align-items: center;
  }

  /* Row 2, col 1: theme switcher */
  .bd-header .navbar-header-items__end .navbar-item:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  /* Row 2, col 2: Помощник button */
  .bd-header .navbar-header-items__end .navbar-item:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  /* Icons list horizontal with equal spacing */
  .bd-header .navbar-icon-links {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around;
    width: 100%;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none;
  }

  .bd-header .navbar-icon-links li {
    padding: 0 !important;
  }

  /* Uniform 36×36 for all icons in 2×2 grid */
  .bd-header .navbar-header-items__end a.pst-navbar-icon {
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    box-sizing: border-box;
  }

  .bd-header .navbar-header-items__end .btn.theme-switch-button {
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  /* Icon-only Помощник button, 36×36 */
  .bd-header #open-docs-bot-btn {
    margin: 0 !important;
    width: 36px !important;
    height: 36px !important;
  }

  .bd-header #open-docs-bot-btn span {
    display: none !important;
  }

  .bd-header #open-docs-bot-btn > div {
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* Changes in various versions */

div.versionchanged {
  border-color: var(--pst-color-info);
  background-color: var(--pst-color-info-bg);
}

span.versionmodified.changed {
  &::before {
    color: var(--pst-color-info);
  }
}

.noborder {
  border: hidden;
}

a.external.image-reference {
  display: inline-flex;
  margin: 0;
}

a.external.image-reference img {
  height: auto;
  padding: 0;
}

/* ============================================
   REDOC IFRAME INTEGRATION
   ============================================ */

html {
  scroll-padding-top: 120px;
}

/* ============================================
   SIDEBAR TOGGLE POSITIONING FIX
   Ensure toggle button is properly aligned with breadcrumbs
   ============================================ */

/* Style for the toggle button in article header */
.bd-header-article .header-article-items__start {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Ensure the toggle button and breadcrumbs align properly */
.bd-header-article .header-article-item {
  display: flex;
  align-items: center;
}

/* Mobile responsiveness */
@media screen and (max-width: 992px) {
  .bd-header-article .header-article-items__start {
    gap: 8px;
  }
}

/* ============================================
   TEXT SELECTION TOOLTIP
   ============================================ */

#aa-selection-tip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  background: #1a2332;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: PT Astra Fact, Verdana, Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  z-index: 9990;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(calc(-100% - 8px));
  transition: opacity 0.12s ease;
}

#aa-selection-tip.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#aa-selection-tip:hover {
  background: #0280fe;
}

#aa-selection-tip span {
  font-size: 13px;
  line-height: 1;
}

#aa-selection-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1a2332;
}

#aa-selection-tip:hover::after {
  border-top-color: #0280fe;
}

/* ─── Consent gate modal ────────────────────────────────────────────────────
   Shown before the panel opens, until the user agrees to store a technical
   identifier in localStorage. */
#aa-consent-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(29, 31, 43, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#aa-consent-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#aa-consent-modal {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  padding: 24px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  font-family: var(--font__base-astra);
  color: var(--aa-graphite-1000);
  transform: translateY(8px);
  transition: transform 0.15s ease;
}

#aa-consent-backdrop.is-visible #aa-consent-modal {
  transform: translateY(0);
}

#aa-consent-modal h3 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
}

#aa-consent-modal p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--aa-graphite-900);
}

.aa-consent-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.aa-consent-btn {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.aa-consent-decline {
  background: transparent;
  border-color: var(--aa-graphite-500);
  color: var(--aa-graphite-900);
}

.aa-consent-decline:hover {
  background: var(--aa-graphite-300);
}

.aa-consent-accept {
  background: var(--aa-blue-500);
  color: #fff;
}

.aa-consent-accept:hover {
  background: var(--aa-blue-700);
}

html[data-theme="dark"] #aa-consent-modal {
  background: var(--aa-graphite-100);
}
