.report-chat-button { margin-top: 1.5rem; max-width: 100%; white-space: normal; }
.report-chat-dialog {
  position: fixed; inset: auto var(--page-gutter) max(.75rem, env(safe-area-inset-bottom)) auto;
  z-index: 15; margin: 0; padding: 0; min-width: 0;
  width: min(47.5rem, calc(100% - 2 * var(--page-gutter)));
  max-width: calc(100% - 2 * var(--page-gutter)); height: 50dvh; max-height: 50dvh;
  border: 1px solid var(--sd-border-strong); border-radius: 1.25rem;
  background: var(--sd-surface); color: var(--sd-text);
  box-shadow: 0 .75rem 2.5rem #44263f2b; overflow: hidden;
}
.report-chat-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
body:has(.report-chat-dialog[open]) { padding-bottom: calc(50dvh + 2rem); }
.chat-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .75rem;
  padding: .75rem 1rem; background: var(--sd-surface); border-bottom: 1px solid var(--sd-border);
}
.chat-header h2 { margin: 0; font: 700 clamp(1rem, 2.4vw, 1.2rem)/1.3 var(--body); overflow-wrap: anywhere; }
#chat-balance { margin: .25rem 0 0; font-size: .8125rem; color: var(--sd-text-muted); }
.chat-close {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--sd-primary); font-size: 1.75rem;
}
.chat-close:hover { background: var(--sd-surface-rose); }
.chat-scroll { min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 1rem; }
.chat-messages { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.chat-message { min-width: 0; max-width: 100%; padding: .75rem 1rem; border-radius: 1rem; overflow-wrap: anywhere; }
.chat-message-user { background: #EFEFF1; color: #2E2A31; margin-left: min(8%, 2.25rem); }
.chat-message-assistant { background: var(--sd-primary); color: var(--sd-text-on-primary); margin-right: min(8%, 2.25rem); }
.chat-author { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; line-height: 1.4; }
.chat-avatar {
  flex: 0 0 2rem; width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover;
  object-position: center 22%; background: var(--sd-surface-rose);
}
.chat-message p { margin: .375rem 0 0; white-space: pre-wrap; font-size: .9375rem; line-height: 1.65; }
.chat-answer { min-width: 0; max-width: 100%; font-size: .9375rem; line-height: 1.65; overflow-x: auto; }
.chat-answer p { white-space: normal; }
.chat-answer a { text-decoration: underline; text-underline-offset: .15em; }
.chat-answer ul, .chat-answer ol { padding-left: 1.25rem; }
.chat-shortfall { padding: 1rem; margin-top: .875rem; background: var(--sd-surface-rose); border: 1px solid var(--sd-border); border-radius: var(--sd-radius-input); }
.chat-shortfall p { margin: 0 0 .75rem; font-size: .875rem; }
#chat-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .625rem;
  min-width: 0; max-width: none; margin: 0; padding: .75rem 1rem;
  background: var(--sd-surface); border-top: 1px solid var(--sd-border);
}
#chat-question {
  min-width: 0; width: 100%; height: 3.5rem; min-height: 3.5rem; max-height: 5rem; resize: none;
  border: 1px solid var(--sd-border-strong); border-radius: var(--sd-radius-input); padding: .625rem .75rem;
  background: var(--sd-surface); color: var(--sd-text); font: inherit; font-size: 1rem; line-height: 1.4;
}
#chat-send { min-height: 3.5rem; max-width: 9rem; padding-inline: 1rem; }
#chat-error { margin: .75rem 0; }
@media(max-width:650px) {
  .chat-header, #chat-form { padding: .625rem .75rem; }
  .chat-scroll { padding: .75rem; }
  .chat-message { padding: .75rem; }
  .chat-message-user { margin-left: 4%; }
  .chat-message-assistant { margin-right: 4%; }
  #chat-send { padding-inline: .75rem; font-size: .8125rem; }
}
