/* Brassline contextual copilot — extends the existing editorial theme. MIT. */
.copilot-entry {
  color: var(--brass-text);
}
.copilot-entry svg,
.copilot-context-button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.copilot-context-button {
  color: var(--brass-text);
  border-color: var(--line-strong);
}
.contextual-copilot {
  inset: 0;
  margin: 0 0 0 auto;
  width: min(580px, 100%);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-width: 0 0 0 1px;
  border-radius: 0;
  overflow: hidden;
}
.contextual-copilot[open] {
  display: flex;
  flex-direction: column;
}
.copilot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.copilot-head .eyebrow {
  color: var(--brass-text);
  font-size: 9px;
}
.copilot-head h2 {
  font-size: 24px;
  letter-spacing: -0.8px;
  margin: 7px 0 0;
}
.copilot-head [data-copilot-close] {
  font-size: 24px;
}
.contextual-copilot form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.copilot-content {
  padding: 22px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  flex: 1;
}
#copilot-intro {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 0 0 16px;
}
.copilot-source-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 22px;
}
.copilot-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.copilot-section-head h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: -0.1px;
}
.copilot-section-head button {
  font-size: 11px;
  background: transparent;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  color: var(--brass-text);
}
[data-copilot-context] {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  background: var(--canvas);
  border-radius: 4px;
  color: var(--ink);
  padding: 14px;
  margin: 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 11px/1.85 var(--mono);
}
.copilot-small {
  font-size: 10px;
  line-height: 1.65;
  color: var(--muted);
  margin: 8px 0 0;
}
.copilot-prompt-label {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  margin: 22px 0 9px;
}
[data-copilot-draft-state] {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
}
#copilot-prompt {
  display: block;
  width: 100%;
  min-height: 132px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.75;
}
.copilot-request-details {
  padding: 13px 0;
  margin: 16px 0 0;
  border-block: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}
.copilot-request-details summary {
  color: var(--ink);
  cursor: pointer;
}
.copilot-request-details p {
  margin: 12px 0;
}
.copilot-request-details a {
  color: var(--brass-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.copilot-result {
  padding: 15px;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  background: var(--hover);
}
.copilot-result p {
  margin: 0 0 6px;
}
.copilot-result p:last-child {
  margin-bottom: 0;
}
.copilot-result small {
  display: block;
  font-size: 10px;
  color: var(--muted);
}
.copilot-result[data-ai-state='loading'] {
  border-color: var(--brass);
}
.copilot-result[data-ai-state='error'] {
  border-color: var(--clay);
  background: var(--clay-soft);
}
.copilot-result[data-ai-state='success'] {
  border-color: var(--moss);
}
.copilot-result .ai-upgrade-link {
  display: block;
  color: var(--brass-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-top: 8px;
}
.copilot-result .ai-retry-button {
  margin-top: 12px;
}
.copilot-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 16px 26px max(16px, env(safe-area-inset-bottom));
  background: var(--surface);
}
.copilot-footer > span {
  font: 9px/1.6 var(--mono);
  color: var(--muted);
}
.copilot-footer .actions {
  margin-left: auto;
}
@media (max-width: 599px) {
  .copilot-head,
  .copilot-content {
    padding: 18px;
  }
  .copilot-head h2 {
    font-size: 22px;
  }
  .copilot-footer {
    padding: 12px 18px max(12px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  [data-copilot-context] {
    max-height: 200px;
  }
  /* Keep the existing mobile breadcrumb legible after adding the global entry. */
  .topbar .breadcrumb {
    flex: 1;
    overflow: hidden;
  }
}
@media (prefers-reduced-motion: reduce) {
  .contextual-copilot,
  .contextual-copilot * {
    scroll-behavior: auto;
  }
}
