.repository-chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 24rem;
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  flex-direction: column;
  background-color: #F9F9F9;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
  border-left: 1px solid #DCDCE0;
  z-index: 35;
  container: repository-chat / inline-size;
}

.resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: ew-resize;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.resize-handle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.resize-handle:active {
  background-color: rgba(0, 0, 0, 0.2);
}

/* Prevent text selection during resize */
body.resizing {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  cursor: ew-resize;
}

.repository-chat-panel.collapsed {
  height: 3rem;
}

.repository-chat-header {
  display: flex;
  height: 48px;
  min-height: 48px;
  padding: 0 20px;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  align-self: stretch;
  background: #F9F9F9;
  border-bottom: 1px solid #DCDCE0;
}

.repository-chat-messages {
  flex-grow: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.repository-chat-form {
  padding: 1rem 1.5rem 1.5rem;
  flex-shrink: 0;
  background: #F9F9F9;
}

.repository-chat-form .ai-chat-input {
  width: 100%;
}

.repository-chat-context:has(> :not(#repository_chat_context_selector), #repository_chat_context_selector > *) {
  margin-bottom: 0.5rem;
}

@media (max-width: 639px) {
  .repository-chat-panel {
    container-type: normal;
  }

  .repository-chat-panel .resize-handle {
    display: none;
  }

  .repository-chat-messages {
    padding: 1rem;
  }

  .repository-chat-form {
    padding: 1rem;
  }
}

/* Seamless at rest (transparent border) on the #F9F9F9 background. */
#repository_chat_form .ai-chat-input:not(:focus-within) {
  border-color: transparent;
}

@keyframes gentle-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.loading-dot {
  animation: gentle-bounce 1s ease-in-out infinite;
}

.legal-fence {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin: 0.75rem 0;
  overflow: hidden;
}

.legal-fence__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0.75rem;
  background-color: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.legal-fence__badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: #6b7280;
}

.legal-fence--clause .legal-fence__badge { color: #D97706; }
.legal-fence--definition .legal-fence__badge { color: #7c3aed; }
.legal-fence--document .legal-fence__badge { color: #2563eb; }

.legal-fence__actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legal-fence__action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #374151;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.1875rem 0.5rem;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}

.legal-fence__action:hover {
  background-color: #f3f4f6;
}

.legal-fence__action svg {
  width: 0.875rem;
  height: 0.875rem;
  flex: none;
}

.legal-fence__body {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: #1f2937;
}

.legal-fence__body p {
  margin-bottom: 0.75rem;
}

.legal-fence__body p:last-child {
  margin-bottom: 0;
}

.legal-fence__body h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.legal-fence__body h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

/* Grounding footer: "Verified by Law Insider" + a link to similar clauses. */
.legal-fence__source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
  font-size: 0.6875rem;
}

.legal-fence__source-note {
  color: #6b7280;
  font-weight: 500;
}

.legal-fence__source-brand {
  color: #111827;
  font-weight: 700;
}

/* The Law Insider wordmark image (swapped in for the text by markdown_controller).
   Sized so the wordmark's cap-height reads at the 11px footer text size. */
.legal-fence__source-logo {
  display: inline-block;
  height: 0.75rem;
  width: auto;
  opacity: 0.8;
  vertical-align: middle;
  position: relative;
  top: -0.5px;
}

/* Law Insider Index score ring (left of the footer). */
.legal-fence__score {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding-right: 0.75rem;
  margin-right: 0.25rem;
  border-right: 1px solid #d1d5db;
}

.legal-fence__ring {
  width: 2rem;
  height: 2rem;
  flex: none;
}

.legal-fence__ring-num {
  font-size: 12px;
  font-weight: 700;
  fill: #374151;
}

.legal-fence__score-label {
  font-weight: 600;
  color: #374151;
}

.legal-fence__source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  color: #374151;
  font-weight: 600;
  text-decoration: none;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.15s;
}

.legal-fence__source-link svg {
  width: 0.8125rem;
  height: 0.8125rem;
  flex: none;
}

.legal-fence__source-link:hover {
  background-color: #e5e7eb;
}

/* Beat the global a:link/a:visited styles for the action + source anchors. */
.legal-fence a.legal-fence__action,
.legal-fence a.legal-fence__action:visited {
  color: #374151;
  text-decoration: none;
}

.legal-fence a.legal-fence__source-link,
.legal-fence a.legal-fence__source-link:visited {
  color: #374151;
  text-decoration: none;
}

/* The request page keeps the open chat panel beside its content rather than under it. */
@media (min-width: 768px) {
  .request-chat-docked {
    padding-right: var(--request-chat-dock-width, 0px);
    transition: padding-right 300ms ease-out;
  }

  body.resizing .request-chat-docked {
    transition: none;
  }
}

/* Docked, the request chat never takes more than half the window, whatever width was saved. */
@media (min-width: 768px) {
  .request-chat-panel {
    max-width: 50vw;
  }
}

/* Request page gutters follow the width the page has, not the window's, so they narrow while
   the chat panel is docked beside it (the docked section's padding is outside its container). */
.request-chat-docked {
  container: request-page / inline-size;
}

.request-page-gutter {
  padding-left: 1rem;
  padding-right: 1rem;
}

@container request-page (min-width: 640px) {
  .request-page-gutter {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@container request-page (min-width: 1024px) {
  .request-page-gutter {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }
}

@container request-page (min-width: 1280px) {
  .request-page-gutter {
    padding-left: 4rem;
    padding-right: 4rem;
  }
}
