#justice-max-chat {
  --jmc-ink: #191917;
  --jmc-gold: var(--color-accent, #f6bf05);
  --jmc-paper: #f8f7f3;
  --jmc-line: #dfddd5;
  --jmc-edge: 16px;
  color: var(--jmc-ink);
  font: 400 16px/1.5 "Source Sans 3", Arial, sans-serif;
  text-align: start;
  color-scheme: light;
}
#justice-max-chat *, #justice-max-chat *::before { box-sizing: border-box; }
#justice-max-chat :is(p, h2, form) { margin: 0; }
#justice-max-chat button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: none;
  cursor: pointer;
}
#justice-max-chat [hidden] { display: none; }
#justice-max-chat svg { display: block; width: 22px; height: 22px; }
#justice-max-chat :focus-visible { outline: 2px solid #926400; outline-offset: 2px; }

/* The Spanish theme keeps its WhatsApp link when the chat composer is unavailable. */
body:has(#justice-max-chat .jmc-composer:not([hidden])) .whatsapp-launcher { display: none; }
#justice-max-chat .jmc-launch:not([hidden]) {
  position: fixed;
  z-index: 30;
  top: 50%;
  right: env(safe-area-inset-right, 0px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 48px;
  padding: 15px 10px;
  border: 1px solid var(--jmc-gold);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #111;
  color: var(--jmc-gold);
  box-shadow: 0 4px 16px #0004;
  transform: translateY(-50%);
}
#justice-max-chat .jmc-launch span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
#justice-max-chat .jmc-launch:hover { color: #111; background: var(--jmc-gold); }
#justice-max-chat .jmc-launch:focus-visible { outline: 2px solid currentColor; outline-offset: -5px; }
body:has(.cookie-notice:not([hidden]), dialog[open]:not(#jmc-panel), .header-menu[aria-expanded="true"]) #justice-max-chat:not(:has(#jmc-panel:modal)),
body:has(form:focus-within) #justice-max-chat .jmc-launch {
  visibility: hidden;
}

#justice-max-chat #jmc-panel {
  position: fixed;
  z-index: 40;
  inset: auto max(var(--jmc-edge), env(safe-area-inset-right)) max(var(--jmc-edge), env(safe-area-inset-bottom)) auto;
  width: min(400px, calc(100% - 2 * var(--jmc-edge)));
  height: min(600px, calc(100dvh - 2 * var(--jmc-edge)));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #221f1b29;
  border-radius: 18px;
  color: var(--jmc-ink);
  background: var(--jmc-paper);
  box-shadow: 0 12px 48px #1b191629, 0 2px 8px #1b19161a;
  font: inherit;
}
#justice-max-chat #jmc-panel[open] { display: flex; flex-direction: column; }
#justice-max-chat #jmc-panel:modal {
  inset: var(--jmc-visible-top, 0px) 0 auto;
  width: 100%;
  height: var(--jmc-visible-height, 100dvh);
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  border: 0;
  border-radius: 0;
}
html:has(#jmc-panel:modal) { overflow: hidden; }
#jmc-panel::backdrop { background: var(--jmc-paper, #f8f7f3); }
#justice-max-chat .jmc-head {
  position: static;
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 17px 16px;
  border-bottom: 3px solid var(--jmc-gold);
  background: var(--jmc-ink);
  color: white;
}
#justice-max-chat #jmc-panel:modal .jmc-head { padding-top: calc(17px + env(safe-area-inset-top)); }
#justice-max-chat .jmc-mark {
  display: grid;
  flex: 0 0 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--jmc-gold);
  color: var(--jmc-ink);
}
#justice-max-chat .jmc-mark svg { width: 26px; height: 26px; }
#justice-max-chat .jmc-mark:has(img) {
  border: 2px solid var(--jmc-gold);
  border-radius: 50%;
  background: transparent;
}
#justice-max-chat .jmc-mark img { display: block; width: 28px; height: auto; }
#justice-max-chat #jmc-title {
  color: inherit;
  font-family: inherit;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  text-transform: none;
}
#justice-max-chat[data-site="Broadway Law"] #jmc-title { color: var(--jmc-gold); }
#justice-max-chat #jmc-assistant { margin-top: 2px; font: inherit; font-size: 14px; color: #dedbd4; }
#justice-max-chat .jmc-close {
  flex: 0 0 44px;
  margin-left: auto;
  border: 1px solid #ffffff40;
  border-radius: 50%;
  background: transparent;
  color: white;
}
#justice-max-chat .jmc-close:hover { background: #ffffff18; }
#justice-max-chat .jmc-close:focus-visible { outline-color: var(--jmc-gold); }
#justice-max-chat .jmc-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 18px;
}
/* Anchor a short conversation above the composer and let longer histories scroll. */
#justice-max-chat .jmc-log > :first-child { margin-top: auto; }
#justice-max-chat .jmc-log p {
  flex: none;
  max-width: 85%;
  padding: 11px 15px;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#justice-max-chat .jmc-outbound {
  align-self: flex-start;
  border: 1px solid var(--jmc-line);
  border-radius: 16px 16px 16px 4px;
  background: white;
}
#justice-max-chat .jmc-inbound {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  background: var(--jmc-ink);
  color: white;
}
#justice-max-chat .jmc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#justice-max-chat .jmc-status { padding: 0 18px 10px; color: #5d5952; font: inherit; font-size: 14px; }
#justice-max-chat .jmc-status:empty { padding: 0; }
#justice-max-chat .jmc-action {
  align-self: flex-start;
  margin: 0 18px 10px;
  padding: 0 14px;
  border: 1px solid var(--jmc-line);
  border-radius: 22px;
  color: var(--jmc-ink);
  background: white;
}
#justice-max-chat .jmc-composer:not([hidden]) {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--jmc-line);
  background: white;
}
#justice-max-chat #jmc-panel:modal .jmc-composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#justice-max-chat textarea {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  max-height: 100px;
  field-sizing: content;
  padding: 10px 14px;
  resize: none;
  border: 1px solid #bab8b0;
  border-radius: 22px;
  color: var(--jmc-ink);
  background: white;
  font: inherit;
}
#justice-max-chat textarea::placeholder { color: #69665f; }
#justice-max-chat [type="submit"] {
  flex: 0 0 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--jmc-ink);
  background: var(--jmc-gold);
}
#justice-max-chat [type="submit"]:enabled:hover { background: var(--color-accent-hover, #dfa900); }
#justice-max-chat button:disabled { background: #edece8; color: #77746e; cursor: default; }
@media print {
  #justice-max-chat, #jmc-panel::backdrop { display: none; }
}
