.chat-launcher {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 14px 22px;
  border-radius: 28px;
  background: var(--blue);
  color: white;
  font-size: 14px;
  font-weight: 650;
  box-shadow: 0 5px 22px #2947b433;
}

.chat-launcher:hover, .chat-send:hover:not(:disabled) { background: var(--blue-dark); }
.chat-launcher[aria-expanded="true"] { background: var(--ink); }

.chat-panel {
  position: fixed;
  z-index: 21;
  right: 28px;
  bottom: 88px;
  width: 440px;
  height: min(700px, calc(100dvh - 112px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border: 1px solid #cdd7ef;
  border-radius: 20px;
  box-shadow: 0 14px 65px #1d2b4b29;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
  flex-shrink: 0;
}

.chat-mark {
  display: grid;
  place-items: center;
  width: 37px;
  height: 40px;
  background: var(--tint);
  color: var(--blue);
  border-radius: 10px;
}

.chat-heading { flex: 1; min-width: 0; }
.chat-heading h2 { font-size: 16px; font-weight: 650; letter-spacing: -.35px; margin: 0 0 3px; }
.chat-heading > span { font-size: 10px; color: var(--muted); }
.chat-header .text-button { font-size: 11px; white-space: nowrap; }
.chat-header .icon-button { width: 28px; height: 28px; min-width: 28px; margin-left: 4px; }
.chat-header .icon-button .icon { width: 16px; height: 16px; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 25px 22px 18px; scroll-padding: 18px; }
.chat-welcome { padding: 5px 2px; }
.chat-welcome-icon { display: grid; place-items: center; width: 47px; height: 47px; border-radius: 14px; background: #fff3d3; color: #87651e; margin-bottom: 19px; }
.chat-welcome-icon .icon { width: 24px; height: 24px; }
.chat-welcome h3 { font-size: 28px; letter-spacing: -.9px; line-height: 1.18; font-weight: 600; margin: 0 0 12px; }
.chat-welcome > p { font-size: 13px; color: var(--muted); line-height: 1.7; margin: 0; max-width: 310px; }
.chat-suggestions { display: grid; gap: 8px; margin: 24px 0 17px; }
.chat-suggestions button { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 15px; background: white; border: 1px solid var(--line); border-radius: 9px; padding: 13px 14px; font-size: 12px; }
.chat-suggestions button:hover { background: var(--tint); border-color: #c2cdf5; }
.chat-suggestions .icon { width: 16px; height: 16px; color: var(--blue); }
.chat-welcome > p.chat-scope { font-size: 10px; line-height: 1.7; max-width: none; }

.chat-messages { display: flex; flex-direction: column; gap: 22px; }
.chat-message { max-width: 100%; overflow-wrap: anywhere; }
.chat-message-label { display: block; font-size: 10px; color: var(--muted); margin: 0 0 7px; font-weight: 600; }
.chat-message.user { align-self: flex-end; max-width: 90%; }
.chat-message.user .chat-message-label { text-align: right; }
.chat-message.user .chat-message-body { padding: 12px 15px; border-radius: 14px 14px 3px 14px; background: var(--tint); white-space: pre-wrap; }
.chat-message-body { font-size: 13px; line-height: 1.8; }
.chat-message-body p { margin: 0 0 10px; }
.chat-message-body p:last-child { margin-bottom: 0; }
.chat-message-body ul { padding-left: 19px; margin: 8px 0 12px; }
.chat-message-body li { margin-bottom: 5px; }
.chat-message-body strong { font-weight: 650; }
.chat-message-body code { font-family: inherit; font-size: 12px; background: #f0f3fa; padding: 1px 4px; border-radius: 3px; }
.chat-sources { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 11px; line-height: 1.6; }
.chat-sources p { margin: 0 0 6px; color: var(--muted); }
.chat-sources ul { margin: 0; padding-left: 17px; }
.chat-sources li { margin: 5px 0; }
.chat-sources a { color: var(--blue); text-decoration: underline; overflow-wrap: anywhere; }
.chat-sources li > span { display: block; color: var(--muted); font-size: 10px; }
.chat-tools { margin-top: 14px; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.chat-tools summary { cursor: pointer; }
.chat-evidence > p { line-height: 1.6; }
.chat-evidence li { margin-bottom: 12px; }
.chat-evidence li p { margin: 3px 0; }
.chat-evidence a { color: var(--blue); text-decoration: underline; }
.chat-tools ul { margin: 8px 0 0; padding-left: 17px; line-height: 1.8; }
.chat-progress { display: flex; align-items: center; gap: 8px; color: var(--blue); font-size: 11px; padding: 11px 22px; background: #f5f8ff; }
.chat-working-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: chat-pulse 1.4s infinite; }
@keyframes chat-pulse { 50% { opacity: .25; } }
.chat-error { font-size: 11px; line-height: 1.7; padding: 12px 22px; background: #fff2e8; color: #834620; max-height: 135px; overflow-y: auto; }
.chat-form { border-top: 1px solid var(--line); padding: 16px 18px 12px; background: white; flex-shrink: 0; }
.chat-composer { display: flex; align-items: flex-end; gap: 10px; border: 1px solid #ced7eb; border-radius: 12px; padding: 10px; }
.chat-composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #3859d914; }
.chat-composer textarea { font: inherit; font-size: 12px; line-height: 1.6; padding: 2px 4px; color: var(--ink); background: transparent; border: 0; outline: 0; resize: none; width: 100%; min-width: 0; max-height: 100px; }
.chat-composer textarea::placeholder { color: #7c879e; }
.chat-send { flex-shrink: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--blue); color: white; }
.chat-send:disabled { opacity: .4; cursor: default; }
.chat-footnote { color: var(--muted); font-size: 9px; line-height: 1.6; text-align: center; margin: 9px 0 0; }

@media(max-width:620px) {
  .chat-launcher { right: 18px; bottom: 18px; min-height: 48px; padding: 12px 18px; font-size: 13px; }
  .chat-panel { right: 10px; bottom: 10px; width: calc(100% - 20px); height: calc(100dvh - 20px); border-radius: 16px; }
  .chat-header { padding: 16px; }
  .chat-scroll { padding: 22px 18px; }
  .chat-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat-composer textarea { font-size: 16px; }
  .chat-footnote { font-size: 9px; }
  .site-footer { padding-bottom: 85px; }
}

.chat-context { flex-shrink: 0; padding: 12px 20px; background: #f5f8ff; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.5; }
.chat-context p { margin: 6px 0; }
.chat-context details { margin: 5px 0; }
.chat-context summary { cursor: pointer; color: var(--blue); }
.chat-context pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 100px; overflow-y: auto; font-size: 10px; margin: 6px 0; }
.chat-context .text-button { font-size: 11px; padding: 3px 0; }
.chat-context .chat-context-privacy { font-size: 10px; color: var(--muted); margin-bottom: 0; }
.chat-context :focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
@media(max-height:700px) { .chat-context { padding: 8px 16px; } .chat-scroll { padding-top: 12px; } }
@media(prefers-reduced-motion:reduce) { .chat-working-dot { animation: none; } }
