.case-ai-dialog {
  color: var(--ink, #1a2c39);
  background: #fff;
  width: min(700px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid var(--line, #dfe5e9);
  border-radius: 14px;
  box-shadow: 0 24px 74px #1b1c343b;
  overflow: auto;
  overscroll-behavior: contain;
}
.case-ai-dialog::backdrop { background: rgba(28, 27, 46, .53); }
.case-ai-dialog[open] { animation: bb-ai-appear .17s ease-out; }
@keyframes bb-ai-appear {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.bb-ai-head {
  padding: 18px 22px 15px;
  border-bottom: 1px solid #e0deeb;
  background: #f8f7fb;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.bb-ai-heading { min-width: 0; }
.bb-ai-heading h2 { color: #282743; font-size: 1.25rem; margin-top: 3px; }
.bb-ai-heading p { color: var(--muted, #61717e); margin-top: 4px; font-size: .85rem; overflow-wrap: anywhere; }
.case-ai-dialog .bb-ai-close { min-height: 38px; width: 38px; padding: 0; flex: 0 0 38px; font-size: 1.35rem; }
.bb-ai-tabs {
  display: flex;
  flex-wrap: wrap;
  column-gap: 15px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line, #dfe5e9);
}
.bb-ai-tabs button {
  min-height: 44px;
  padding: 9px 3px 7px;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted, #61717e);
  font-weight: 650;
  line-height: 1.35;
  font-size: .86rem;
}
.bb-ai-tabs button[aria-selected="true"] { color: #0c6355; border-bottom-color: var(--teal, #117c69); }
.bb-ai-tabs button:focus-visible { outline-offset: -3px; }
.bb-ai-panel { padding: 17px 22px 22px; }
.bb-ai-panel > * + *, .bb-ai-stack > * + * { margin-top: 12px; }
.bb-ai-tones { border: 0; padding: 0; margin: 0; }
.bb-ai-tones legend { padding: 0; margin-bottom: 8px; font-size: .86rem; font-weight: 700; }
.bb-ai-tones label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 5px 5px 0;
  padding: 6px 9px;
  border: 1px solid var(--line, #dfe5e9);
  border-radius: 7px;
  cursor: pointer;
  font-size: .85rem;
}
.bb-ai-tones label:has(:checked) { background: #e9f4f0; border-color: #b5d6ca; }
.bb-ai-tones input { accent-color: var(--teal, #117c69); margin: 0; }
.bb-ai-actions, .bb-ai-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bb-ai-actions:empty { display: none; }
.bb-ai-actions:has(> button[hidden]:only-child) { display: none; }
.bb-ai-footer { justify-content: flex-end; }
.case-ai-dialog .btn:not(.primary):hover { background: #f3f7f7; }
.case-ai-dialog .btn:disabled { opacity: .65; cursor: default; }
.case-ai-dialog .bb-ai-whatsapp { color: #0c6355; background: #e9f4f0; border-color: #d0e4dc; text-decoration: none; }
.case-ai-dialog .bb-ai-chips .btn {
  text-align: left;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 17px;
  font-size: .8rem;
}
.bb-ai-field { display: grid; gap: 5px; font-size: .88rem; font-weight: 650; }
.bb-ai-field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #ced9df;
  border-radius: 7px;
  color: var(--ink, #1a2c39);
  background: #fff;
  resize: vertical;
  font-weight: 400;
  line-height: 1.5;
}
.bb-ai-feedback, .bb-ai-note { color: var(--muted, #61717e); font-size: .8rem; line-height: 1.5; }
.bb-ai-note:empty { display: none; }
.bb-ai-feedback:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.bb-ai-feedback.is-pending { color: #0c6355; display: flex; gap: 8px; align-items: center; }
.bb-ai-feedback.is-pending::before {
  content: "";
  flex: 0 0 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #bdd9d2;
  border-top-color: var(--teal, #117c69);
  animation: bb-ai-spin .7s linear infinite;
}
@keyframes bb-ai-spin { to { transform: rotate(360deg); } }
.bb-ai-blocks { display: grid; gap: 6px; margin: 0; }
.bb-ai-blocks > div { padding: 9px 11px; background: #f8faf9; border: 1px solid var(--line, #dfe5e9); border-radius: 7px; min-width: 0; }
.bb-ai-blocks dt { color: #514c66; font-weight: 700; font-size: .82rem; margin-bottom: 4px; }
.bb-ai-blocks dd, .bb-ai-answer { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; line-height: 1.55; }
.bb-ai-blocks ul { padding-left: 19px; margin: 0; }
.bb-ai-answer { border-left: 3px solid var(--teal, #117c69); background: #f3f8f6; border-radius: 5px; padding: 11px 13px; }
.case-ai-dialog mark { background: #ffe894; color: #503909; border-radius: 3px; padding: 0 2px; font-weight: 700; }
.bb-ai-review, .bb-ai-error { padding: 9px 11px; border: 1px solid #ecd491; background: #fff7df; color: #704910; border-radius: 7px; font-size: .85rem; }
.bb-ai-error { border-color: #ebc6ca; background: #fff2f3; color: #872833; overflow-wrap: anywhere; }
@media (max-width: 540px) {
  .bb-ai-head, .bb-ai-panel { padding-left: 14px; padding-right: 14px; }
  .bb-ai-tabs { padding: 0 14px; column-gap: 9px; }
  .bb-ai-tabs button { flex: 1 1 28%; min-width: 0; font-size: .79rem; white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .case-ai-dialog[open], .bb-ai-feedback.is-pending::before { animation: none; }
}

.case-ai-trigger { gap: 7px; }
.case-ai-trigger::before, .case-ai-document::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  background: currentColor;
  clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%);
}
.file-document .case-ai-document { color: #0c6355; background: #edf6f2; border-color: #d2e7df; }
.file-document .case-ai-document:hover { background: #e1f1eb; }
.case-ai-review { padding: 11px 13px; border: 1px solid #ecd491; background: #fff7df; color: #704910; border-radius: 7px; }
.case-ai-review p { margin: 0 0 7px; font-size: .86rem; }
.case-ai-review .check-field { margin: 0; }
.bb-ai-docs { border: 1px solid var(--line, #dfe5e9); border-radius: 8px; padding: 9px 11px; margin: 0; background: #fafbfc; }
.bb-ai-docs legend { padding: 0 4px; font-size: .82rem; font-weight: 700; color: #394452; }
.bb-ai-docs legend span { font-weight: 500; color: var(--muted, #61717e); }
.bb-ai-docs-list { display: grid; gap: 5px; max-height: 135px; overflow-y: auto; margin-top: 4px; }
.bb-ai-docs-list label { display: flex; align-items: center; gap: 7px; font-size: .82rem; cursor: pointer; padding: 3px 5px; border-radius: 5px; }
.bb-ai-docs-list label:hover { background: #eef3f5; }
.bb-ai-docs-list input { accent-color: var(--teal, #117c69); margin: 0; flex: 0 0 auto; }
.bb-ai-docs-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
