/* ==========================================================================
   KB Chat: member answer display
   ========================================================================== */

.kb-chat-answer h2 {
  font-size: var(--md-sys-typescale-body-large-size);
  margin-bottom: 0.25rem;
}

.kb-chat-answer {
  margin-top: var(--space-6);
}

.kb-chat-answer h2:not(:first-child) {
  margin-top: 1rem;
}

.kb-chat-rating {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

.kb-chat-rating form {
  margin: 0;
}

.kb-chat-citation-list {
  margin: 0.5rem 0;
}

.kb-chat-citation-list h3 {
  font-size: var(--md-sys-typescale-body-large-size);
  margin: 0 0 0.25rem;
}

.kb-chat-divider {
  border: 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  margin: 1rem 0;
}

.kb-chat-citation-list ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.kb-chat-signal-icons {
  display: inline-flex;
  gap: 0.35rem;
}

.kb-chat-filter-form summary {
  cursor: pointer;
  font-weight: var(--meta-strong-weight);
  margin-bottom: 0.5rem;
}

.kb-chat-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 1rem;
}

.kb-chat-filter-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--meta-size);
}

.kb-health-item {
  margin-bottom: 1rem;
}

/* ==========================================================================
   Crawl progress summary and diagnostic log viewer (work item #208)
   ========================================================================== */

.crawl-progress-meta {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
  font-size: var(--meta-size);
  line-height: var(--meta-line-height);
}

.crawl-progress-meta dt {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
}

.crawl-progress-meta dd {
  margin: 0;
}

.crawl-log-viewer {
  margin: 1rem 0 0;
}

.crawl-log-viewer > summary {
  cursor: pointer;
  font-weight: var(--meta-strong-weight);
}

.crawl-log {
  max-height: 14rem;
  overflow: auto;
  margin: 0.5rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.crawl-log-viewer .field-hint {
  margin-top: 0.5rem;
}

.crawl-failed-page-url,
.crawl-failed-page-error {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.crawl-failed-page-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.crawl-failed-page-row > :first-child {
  min-width: 0;
}

.crawl-failed-page-row form {
  flex: 0 0 auto;
  margin: 0;
}

@media (max-width: 599px) {
  .crawl-progress-meta {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .crawl-failed-page-row {
    flex-direction: column;
  }
}

/* ==========================================================================
   KB Chat: ask-form mill animation (work item #211)
   ========================================================================== */

.kb-chat-mill {
  display: none;
  margin: 0.5rem 0 0;
}

form[aria-busy="true"] .kb-chat-mill {
  display: block;
}

.kb-chat-mill-scene {
  display: block;
  width: 100%;
  max-width: 28rem;
  height: auto;
  margin-inline: 0;
  overflow: visible;
}

.kb-chat-mill-scene [data-fill="surface"] {
  fill: var(--md-sys-color-surface-container-high);
}

.kb-chat-mill-scene [data-fill="surface-lowest"] {
  fill: var(--md-sys-color-surface-container-lowest);
}

.kb-chat-mill-scene [data-fill="primary"] {
  fill: var(--md-sys-color-primary);
}

.kb-chat-mill-scene [data-fill="primary-container"] {
  fill: var(--md-sys-color-primary-container);
}

.kb-chat-mill-scene [data-fill="on-primary-container"] {
  fill: var(--md-sys-color-on-primary-container);
}

.kb-chat-mill-scene [data-fill="secondary-container"] {
  fill: var(--md-sys-color-secondary-container);
}

.kb-chat-mill-scene [data-stroke="outline"] {
  stroke: var(--md-sys-color-outline-variant);
  fill: none;
}

.kb-chat-mill-scene [data-stroke="primary"] {
  stroke: var(--md-sys-color-primary);
  fill: none;
}

.kb-chat-mill-scene [data-stroke="on-container"] {
  stroke: var(--md-sys-color-on-primary-container);
  fill: none;
}

.kb-chat-mill-scene [data-stroke="on-secondary"] {
  stroke: var(--md-sys-color-on-secondary-container);
  fill: none;
}

.kb-chat-mill-scene [data-fill="on-secondary"] {
  fill: var(--md-sys-color-on-secondary-container);
}

.kb-chat-mill-source,
.kb-chat-mill-answer,
.kb-chat-mill-gear,
.kb-chat-mill-bar,
.kb-chat-mill-eye,
.kb-chat-mill-belt-marks {
  transform-box: fill-box;
  transform-origin: center;
}

.kb-chat-mill-bar {
  transform-origin: center bottom;
}

.kb-chat-mill-source--web {
  animation: kb-chat-mill-ingest 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.kb-chat-mill-source--doc {
  animation: kb-chat-mill-ingest 6s cubic-bezier(0.4, 0, 0.2, 1) 2s infinite;
}

.kb-chat-mill-source--book {
  animation: kb-chat-mill-ingest 6s cubic-bezier(0.4, 0, 0.2, 1) 4s infinite;
}

.kb-chat-mill-answer {
  animation: kb-chat-mill-emit 6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.kb-chat-mill-gear {
  animation: kb-chat-mill-spin 4s linear infinite;
}

.kb-chat-mill-bar {
  animation: kb-chat-mill-bars 0.9s ease-in-out infinite;
}

.kb-chat-mill-bar:nth-child(2) {
  animation-delay: 0.15s;
}

.kb-chat-mill-bar:nth-child(3) {
  animation-delay: 0.3s;
}

.kb-chat-mill-eye {
  animation: kb-chat-mill-blink 3.2s ease-in-out infinite;
}

.kb-chat-mill-belt-marks {
  animation: kb-chat-mill-belt 1.2s linear infinite;
}

@keyframes kb-chat-mill-ingest {
  0% { transform: translateX(0); opacity: 0; }
  8% { opacity: 1; }
  70% { transform: translateX(108px); opacity: 1; }
  84% { transform: translateX(128px); opacity: 0; }
  100% { transform: translateX(128px); opacity: 0; }
}

@keyframes kb-chat-mill-emit {
  0%, 46% { transform: translateX(-18px); opacity: 0; }
  60% { transform: translateX(0); opacity: 1; }
  86% { transform: translateX(8px); opacity: 1; }
  100% { transform: translateX(22px); opacity: 0; }
}

@keyframes kb-chat-mill-spin {
  to { transform: rotate(360deg); }
}

@keyframes kb-chat-mill-bars {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

@keyframes kb-chat-mill-blink {
  0%, 86%, 100% { transform: scaleY(1); }
  90% { transform: scaleY(0.12); }
}

@keyframes kb-chat-mill-belt {
  to { stroke-dashoffset: -18; }
}

@media (prefers-reduced-motion: reduce) {
  .kb-chat-mill-source,
  .kb-chat-mill-answer,
  .kb-chat-mill-gear,
  .kb-chat-mill-bar,
  .kb-chat-mill-eye,
  .kb-chat-mill-belt-marks {
    animation: none;
  }

  .kb-chat-mill-source--web {
    transform: translateX(88px);
    opacity: 1;
  }

  .kb-chat-mill-source--doc {
    transform: translateX(44px);
    opacity: 1;
  }

  .kb-chat-mill-source--book {
    transform: translateX(0);
    opacity: 1;
  }

  .kb-chat-mill-answer {
    transform: none;
    opacity: 1;
  }
}

/* Crawl-site Excluded URLs rows (#264): long exact URLs must wrap inside
   the inline remove form instead of overflowing the panel. */
.crawl-excluded-url {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   KB Admin: chat-agent-name info box (work item #284)
   ========================================================================== */

.kb-agent-name-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
}

/* The configured name is what the box is about, so it takes the section-head
   role — emphatic beside the meta-sized hint below it, without inventing a
   third weight or size. The unconfigured state drops back to the meta role on
   purpose: it is a placeholder, not a value. */
.kb-agent-name-value {
  color: var(--md-sys-color-on-surface);
  font-size: var(--section-head-size);
  line-height: var(--section-head-line-height);
  font-weight: var(--section-head-weight);
}

.kb-agent-name-value--unset {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--meta-size);
  line-height: var(--meta-line-height);
  font-weight: var(--meta-weight);
}

.kb-agent-name-display > .field-hint {
  margin-top: 0.55rem;
}

/* Quiet, borderless edit affordance beside the displayed value — the same
   treatment as the Work Board's inline edit buttons, at the shared 44px
   control size. */
.kb-agent-name-edit {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.65rem;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
}

.kb-agent-name-edit:hover {
  background: color-mix(in oklch, currentColor 10%, transparent);
}

.kb-agent-name-edit:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.kb-agent-name-edit svg {
  display: block;
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

/* The inline editor keeps the bounded width the design mockup was signed
   off with, rather than the full-panel width stacked forms use. */
.kb-agent-name-form .form-field {
  max-width: 24rem;
}

.kb-document-value {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.kb-document-edit {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.65rem;
  border: 0;
  border-radius: var(--md-sys-shape-corner-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
}

.kb-document-edit:hover { background: color-mix(in oklch, currentColor 10%, transparent); }
.kb-document-edit:focus-visible { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }
.kb-document-edit svg { display: block; width: 1rem; height: 1rem; fill: currentColor; }

.kb-document-edit-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.kb-document-edit-form[hidden] { display: none; }
.kb-document-edit-form input:not([type="hidden"]) { flex: 1 1 18rem; min-width: 0; }
.kb-document-replace .form-field { margin-bottom: 0; }
.kb-document-actions { margin-top: 1.5rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.kb-document-actions form { margin: 0; }

@media (max-width: 599px) {
  .kb-document-edit-form { align-items: stretch; }
  .kb-document-edit-form input:not([type="hidden"]) { flex-basis: 100%; }
}

.kb-chat-scopes label {
  display: block;
  margin-block: var(--space-2);
}

.kb-chat-scopes .field-hint {
  display: block;
  margin-inline-start: var(--space-6);
}

.kb-chat-conflicts {
  border: 1px solid var(--md-sys-color-error);
  border-inline-start-width: 5px;
  border-radius: var(--md-sys-shape-corner-medium);
  padding: var(--space-4);
  margin: var(--space-4) 0;
  background: color-mix(in srgb, var(--md-sys-color-error-container) 40%, var(--md-sys-color-surface));
}

.kb-chat-conflicts h3 {
  margin-top: 0;
}

.conflict-claim {
  padding: var(--space-3);
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-surface);
  margin-top: var(--space-3);
}

.conflict-claim strong {
  display: block;
  margin-bottom: var(--space-1);
}

.kb-chat-answer mark {
  background: var(--md-sys-color-error-container);
  color: inherit;
  border-radius: var(--md-sys-shape-corner-small);
  padding: 0 0.15em;
}

.kb-chat-citation-list li,
.kb-chat-conflicts,
.kb-chat-answer mark {
  overflow-wrap: anywhere;
}
