/* chatBHT grayscale identity for Jupyter Book (PyData/Sphinx Book Theme). */

html:not([data-theme]),
html[data-theme="light"] {
  --pst-color-primary: #525252;
  --pst-color-secondary: #3a3a3a;
  --pst-color-accent: #737373;

  --pst-color-background: #fafafa;
  --pst-color-on-background: #fafafa;
  --pst-color-surface: #f5f5f5;
  --pst-color-on-surface: #f5f5f5;

  --pst-color-text-base: #212121;
  --pst-color-text-muted: #525252;
  --pst-color-border: #d4d4d4;

  --pst-color-link: var(--pst-color-primary);
  --pst-color-link-hover: var(--pst-color-secondary);
  --pst-color-inline-code: #3a3a3a;

  --pst-color-success: #525252;
  --pst-color-info: #737373;
  --pst-color-warning: #737373;
  --pst-color-danger: #525252;
}

html[data-theme="dark"] {
  --pst-color-primary: #d4d4d4;
  --pst-color-secondary: #a3a3a3;
  --pst-color-accent: #737373;

  --pst-color-background: #212121;
  --pst-color-on-background: #212121;
  --pst-color-surface: #262626;
  --pst-color-on-surface: #262626;

  --pst-color-text-base: #fafafa;
  --pst-color-text-muted: #a3a3a3;
  --pst-color-border: #525252;

  --pst-color-link: var(--pst-color-primary);
  --pst-color-link-hover: var(--pst-color-secondary);
  --pst-color-inline-code: #d4d4d4;

  --pst-color-success: #a3a3a3;
  --pst-color-info: #d4d4d4;
  --pst-color-warning: #a3a3a3;
  --pst-color-danger: #d4d4d4;
}

/* Make current/active nav states grayscale as well. */
.bd-sidebar-primary .nav .current > .reference,
.bd-sidebar-primary .nav .active > .reference,
.bd-links .current > a.reference,
.bd-links .active > a.reference {
  color: var(--pst-color-primary);
}

#pst-primary-sidebar-modal.chatbht-dialog-fallback-open {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(88vw, 22rem);
  max-width: 22rem;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 1rem;
  overflow-y: auto;
  border: 0;
  background: var(--pst-color-background, #ffffff);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.28);
  z-index: 2000;
}

/* Neutralize inline code backgrounds to fit grayscale identity. */
code.literal,
.bd-content code.literal {
  background: color-mix(in srgb, var(--pst-color-surface) 84%, var(--pst-color-border));
  border: 1px solid var(--pst-color-border);
}

/* Branded GitLab archive statement. The three marks remain in one row on phones. */
.chatbht-archive-brand {
  max-width: 820px;
  margin: 1rem auto 1.5rem !important;
  padding: clamp(0.9rem, 3vw, 1.4rem);
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgb(17 24 39 / 0.08);
}

.chatbht-archive-brand__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: clamp(0.35rem, 2vw, 1rem);
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.bd-content section .chatbht-archive-brand__row img,
.chatbht-archive-brand__row img {
  display: block;
  width: 100%;
  height: auto;
  max-height: clamp(42px, 9vw, 82px);
  margin: 0;
  object-fit: contain;
  filter: none !important;
  background: transparent !important;
  border-radius: 0 !important;
}

.chatbht-archive-brand__chatbht {
  justify-self: start;
  max-width: clamp(96px, 24vw, 210px);
}

.chatbht-archive-brand__heart {
  width: clamp(32px, 7vw, 52px) !important;
  justify-self: center;
}

.chatbht-archive-brand__gitlab {
  justify-self: end;
  max-width: clamp(96px, 24vw, 210px);
}

.chatbht-archive-brand figcaption {
  max-width: 680px;
  margin: 0.85rem auto 0;
  color: #4b5563;
  font-size: clamp(0.76rem, 2.4vw, 0.9rem);
  line-height: 1.45;
  text-align: center;
}

/* Flow from prompt to a version-bound citation. */
.chatbht-evidence-flow {
  --evidence-flow-panel: #ffffff;
  --evidence-flow-soft: #f9fafb;
  --evidence-flow-text: #1f2937;
  --evidence-flow-muted: #6b7280;
  --evidence-flow-border: #d1d5db;
  max-width: 760px;
  margin: 1rem auto 1.5rem !important;
  padding: clamp(0.8rem, 2vw, 1.25rem);
  border: 1px solid var(--evidence-flow-border);
  border-radius: 12px;
  color: var(--evidence-flow-text);
  background: var(--evidence-flow-soft);
}

html[data-theme="dark"] .chatbht-evidence-flow {
  --evidence-flow-panel: #374151;
  --evidence-flow-soft: #1f2937;
  --evidence-flow-text: #f3f4f6;
  --evidence-flow-muted: #d1d5db;
  --evidence-flow-border: #4b5563;
}

.chatbht-evidence-flow *,
.chatbht-evidence-flow *::before,
.chatbht-evidence-flow *::after {
  box-sizing: border-box;
}

.chatbht-evidence-flow__track {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  width: min(100%, 620px);
  margin: 0;
  margin-inline: auto;
  padding: 0;
  list-style: none;
}

.chatbht-evidence-flow__node {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem 0.75rem;
  min-height: 112px;
  padding: 0.9rem 3.15rem 0.9rem 0.9rem;
  border: 1px solid var(--evidence-flow-border);
  border-radius: 10px;
  background: var(--evidence-flow-panel);
  text-align: left;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.05);
}

.chatbht-evidence-flow__step {
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  color: var(--evidence-flow-muted);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.chatbht-evidence-flow__icon {
  width: 42px;
  height: 42px;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--evidence-flow-text);
  background: var(--evidence-flow-soft);
}

.chatbht-evidence-flow__icon svg {
  width: 23px;
  height: 23px;
  stroke-width: 1.8;
}

.chatbht-evidence-flow__node strong {
  color: var(--evidence-flow-text);
  font-size: 0.92rem;
  line-height: 1.2;
}

.chatbht-evidence-flow__node > span:last-child {
  color: var(--evidence-flow-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.chatbht-evidence-flow__transfer {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 72px;
  color: var(--evidence-flow-muted);
  text-align: center;
}

.chatbht-evidence-flow__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 26px;
  padding: 0.22rem 0.58rem;
  border: 1px solid var(--evidence-flow-border);
  border-radius: 999px;
  color: var(--evidence-flow-text);
  background: var(--evidence-flow-panel);
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.2;
}

.chatbht-evidence-flow__exchange {
  display: grid;
  gap: 0.45rem;
  min-width: min(100%, 310px);
}

.chatbht-evidence-flow__exchange-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) 34px minmax(7rem, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.chatbht-evidence-flow__exchange-row:first-child .chatbht-evidence-flow__badge {
  justify-self: end;
}

.chatbht-evidence-flow__exchange-row:first-child .chatbht-evidence-flow__arrow {
  grid-column: 2;
}

.chatbht-evidence-flow__exchange-row:last-child .chatbht-evidence-flow__arrow {
  grid-column: 2;
}

.chatbht-evidence-flow__exchange-row:last-child .chatbht-evidence-flow__badge {
  grid-column: 3;
  justify-self: start;
}

.chatbht-evidence-flow__arrow {
  position: relative;
  width: 2px;
  height: 30px;
  display: block;
  justify-self: center;
  border-radius: 999px;
  background: currentColor;
}

.chatbht-evidence-flow__arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.chatbht-evidence-flow__arrow--down::after {
  bottom: 0;
  transform: translate(-50%, 1px) rotate(45deg);
}

.chatbht-evidence-flow__arrow--up::after {
  top: 0;
  transform: translate(-50%, -1px) rotate(225deg);
}

.chatbht-evidence-flow figcaption {
  margin-top: 0.85rem;
  color: var(--evidence-flow-muted);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
}


/* The restored diagrams also stand alone, with no surrounding preview box. */
.chatbht-archive-brand, .chatbht-evidence-flow { border: 0; padding: 0; background: transparent; box-shadow: none; max-width: 560px; }
.chatbht-evidence-flow { --evidence-flow-panel: var(--pst-color-background); --evidence-flow-soft: var(--pst-color-surface); --evidence-flow-text: var(--pst-color-text-base); --evidence-flow-muted: var(--pst-color-text-muted); --evidence-flow-border: var(--pst-color-border); }
.chatbht-evidence-flow__exchange { min-width: 0; width: 100%; }
.chatbht-evidence-flow__exchange-row { grid-template-columns: minmax(0,1fr) 34px minmax(0,1fr); }
html[data-theme="dark"] .chatbht-archive-brand__chatbht,
html[data-theme="dark"] .cbht-login-layer-logo { filter: invert(1) !important; }
html[data-theme="dark"] .chatbht-archive-brand__gitlab { background: #fff !important; border-radius: 5px !important; padding: 6px; }
