/* Marked Help Assistant — web help only */
/* Use px for font sizes: help site sets html { font-size: 62.5% } so rem is tiny */

/* Bottom dock: Ask (always) + back-to-top slot (on scroll) */
.mha-dock {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9000;
  display: flex;
  align-items: center;
  border-radius: 999px;
  background: #1e293b;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.mha-dock:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.mha-dock-ask {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0.65rem 1.15rem 0.65rem 1.25rem;
  font: 600 15px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.mha-dock-ask:hover,
.mha-dock-open .mha-dock-ask {
  background: #334155;
}

.mha-dock-divider {
  flex: 0 0 0;
  width: 0;
  align-self: stretch;
  margin: 0;
  background: rgba(255, 255, 255, 0.22);
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
}

.mha-dock-top {
  flex: 0 0 0;
  width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease, background 0.2s ease,
    width 0.2s ease, flex-basis 0.2s ease;
}

.mha-dock-top svg {
  stroke: #fff;
  flex-shrink: 0;
}

.mha-dock-top:hover {
  background: #334155;
}

.mha-dock-scrolled .mha-dock-divider {
  flex: 0 0 1px;
  width: 1px;
  margin: 10px 0;
  opacity: 1;
}

.mha-dock-scrolled .mha-dock-top {
  flex: 0 0 44px;
  width: 44px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mha-panel {
  position: fixed;
  right: 32px;
  bottom: calc(32px + 52px);
  top: auto;
  z-index: 9001;
  width: min(46rem, calc(100vw - 64px));
  height: min(calc(42rem + 3.5rem), calc(100vh - 120px));
  max-height: min(calc(42rem + 3.5rem), calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 16px;
  line-height: 1.5;
}

.mha-panel[hidden] {
  display: none !important;
}

.mha-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 0.75rem 0.9rem;
  background: #f5f7fb;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font: 600 16px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mha-header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.mha-expand,
.mha-close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #555;
  padding: 0 0.2rem;
}

.mha-expand {
  font-size: 18px;
  padding: 0.15rem 0.35rem;
}

.mha-expand:hover,
.mha-close:hover {
  color: #222;
}

.mha-chat,
.mha-page-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-size: 16px;
  line-height: 1.5;
}

.mha-panel .mha-chat {
  flex: 1 1 auto;
  min-height: 0;
}

.mha-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.9rem;
  background: #fafbfd;
  overscroll-behavior: contain;
}

.mha-message {
  margin-bottom: 0.85rem;
}

.mha-message-user {
  text-align: right;
}

.mha-bubble {
  display: inline-block;
  max-width: 98%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
}

.mha-bubble p,
.mha-bubble li,
.mha-bubble ul,
.mha-bubble a,
.mha-bubble strong {
  font-size: 16px;
  line-height: 1.5;
}

.mha-message-user .mha-bubble {
  background: #2d6cdf;
  color: #fff;
}

.mha-message-bot .mha-bubble {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #222;
}

.mha-form {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
}

.mha-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mha-send {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  background: #2d6cdf;
  color: #fff;
  font: 600 16px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.mha-send:hover {
  background: #2458b8;
}

.mha-results {
  margin: 0.6rem 0 0;
  padding-left: 1.25rem;
}

.mha-results li {
  margin-bottom: 0.85rem;
}

.mha-results a,
.mha-results a strong {
  font-size: 16px;
  line-height: 1.45;
}

.mha-snippet {
  margin: 0.35rem 0 0;
  color: #444;
  font-size: 15px;
  line-height: 1.5;
}

.mha-footnote,
.mha-suggestions-label {
  margin-top: 0.85rem;
  font-size: 14px;
  line-height: 1.45;
  color: #666;
}

.mha-suggestions {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
}

.mha-suggestion {
  display: block;
  width: 100%;
  margin: 0.35rem 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(45, 108, 223, 0.25);
  border-radius: 8px;
  background: #f3f7ff;
  color: #1f4ea8;
  text-align: left;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.mha-suggestion:hover {
  background: #e8f0ff;
}

.mha-thinking {
  color: #666;
  font-style: italic;
  font-size: 16px;
  margin: 0;
}

.mha-page-ask {
  margin: 2rem 0 1.5rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid rgba(45, 108, 223, 0.2);
  border-radius: 10px;
  background: #f7faff;
}

.mha-page-ask-title {
  margin: 0 0 0.35rem;
  font-size: 20px;
  line-height: 1.3;
}

.mha-page-ask-desc {
  margin: 0 0 0.85rem;
  color: #444;
  font-size: 15px;
  line-height: 1.45;
}

.mha-page-ask-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mha-page-ask-row {
  display: flex;
  gap: 0.5rem;
}

.mha-page-ask-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mha-page-ask-submit {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  background: #2d6cdf;
  color: #fff;
  font: 600 16px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.mha-page-ask-submit:hover {
  background: #2458b8;
}

#content.ask .mha-page-chat {
  min-height: 28rem;
  height: 60vh;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

#content.ask .mha-messages {
  flex: 1 1 0;
  min-height: 0;
}

.mha-external-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(45, 108, 223, 0.12);
  color: #2458b8;
  font: 11px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  vertical-align: middle;
}

@media (max-width: 1000px) {
  .mha-dock {
    bottom: 20px;
    right: 20px;
  }

  .mha-panel {
    right: 20px;
    bottom: calc(20px + 52px);
    width: min(46rem, calc(100vw - 40px));
    height: min(calc(42rem + 3.5rem), calc(100vh - 100px));
    max-height: min(calc(42rem + 3.5rem), calc(100vh - 100px));
  }
}

@media print {
  .mha-dock,
  .mha-panel {
    display: none !important;
  }
}
