/* Brain OS docs assistant — floating "Ask Brain" launcher + panel.
   Colours inherit mdBook's theme variables so it matches light/dark/ayu. */

#brain-ask-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  /* mdBook sets html{font-size:62.5%} (1rem=10px), so anchor an explicit base
     here and size children in em — otherwise everything renders ~8px. */
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--sidebar-bg, #fff);
  background: var(--links, #1f6feb);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
#brain-ask-launcher:hover { filter: brightness(1.08); }
#brain-ask-launcher .brain-ask-dot { font-size: 1.1em; line-height: 1; }

#brain-ask-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1001;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(640px, calc(100vh - 2rem));
  display: none;
  flex-direction: column;
  border: 1px solid var(--theme-popup-border, rgba(128, 128, 128, 0.3));
  border-radius: 0.6rem;
  background: var(--bg, #fff);
  color: var(--fg, #333);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  /* Base size for the panel; children scale from this in em (see launcher note). */
  font-size: 1.5rem;
}
#brain-ask-panel.open { display: flex; }

.brain-ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--theme-popup-border, rgba(128, 128, 128, 0.2));
}
.brain-ask-head strong { font-size: 1.05em; }
.brain-ask-head .brain-ask-close {
  border: none;
  background: none;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}
.brain-ask-head .brain-ask-close:hover { opacity: 1; }

.brain-ask-form { display: flex; gap: 0.4rem; padding: 0.75rem 0.9rem; }
.brain-ask-form input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--theme-popup-border, rgba(128, 128, 128, 0.4));
  border-radius: 0.4rem;
  background: var(--theme-hover, transparent);
  color: inherit;
  font: inherit;
}
.brain-ask-form button {
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 0.4rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--sidebar-bg, #fff);
  background: var(--links, #1f6feb);
}
.brain-ask-form button:disabled { opacity: 0.5; cursor: default; }

.brain-ask-results { overflow-y: auto; padding: 0 0.9rem; }
/* Each result is an <a>. mdBook's chrome.css sets a GLOBAL `a:visited { color:
   var(--links) }`, so once you've opened a linked page the row's visited state
   flips the title colour. Pin the row colour across :link/:visited (higher
   specificity than mdBook's bare `a:visited`) and force the title colour so a
   result looks identical whether or not it's been opened. */
.brain-ask-hit,
.brain-ask-hit:link,
.brain-ask-hit:visited {
  display: block;
  padding: 0.7rem 0;
  border-top: 1px solid var(--theme-popup-border, rgba(128, 128, 128, 0.15));
  color: inherit;
  text-decoration: none;
}
.brain-ask-hit:first-child { border-top: none; }
.brain-ask-hit:hover .brain-ask-hit-title { text-decoration: underline; }
.brain-ask-hit-title {
  font-weight: 600;
  color: var(--links, #1f6feb) !important;
  font-size: 0.95em;
}
.brain-ask-hit-snippet {
  margin: 0.25rem 0 0;
  font-size: 0.9em;
  color: var(--fg, #333); /* explicit so it can't inherit a :visited link colour */
  opacity: 0.85;
  line-height: 1.45;
}

.brain-ask-status { padding: 0.5rem 0.9rem 0.25rem; font-size: 0.9em; opacity: 0.75; }

.brain-ask-foot {
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--theme-popup-border, rgba(128, 128, 128, 0.2));
  font-size: 0.8em;
  opacity: 0.7;
  line-height: 1.4;
}
.brain-ask-foot code { font-size: 0.95em; }
