html.user-chat-scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
}
body.user-chat-scroll-locked {
  position: fixed;
  top: var(--user-chat-page-scroll-offset, 0px);
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.user-chat-scroll-locked #app > header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
}

.user-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .24);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.user-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 15px 36px rgba(0, 0, 0, .3); }
.user-chat-launcher:disabled { cursor: default; pointer-events: auto; transform: none; box-shadow: 0 12px 32px rgba(0, 0, 0, .24); }
.user-chat-launcher svg { width: 27px; height: 27px; }
.user-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  pointer-events: none;
}
.user-chat-panel {
  --user-chat-top-boundary: 0px;
  --user-chat-available-height: max(0px, calc(100dvh - var(--user-chat-top-boundary) - 104px));
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 81;
  display: flex;
  width: min(440px, calc(100vw - 28px));
  height: min(620px, var(--user-chat-available-height));
  min-height: min(430px, var(--user-chat-available-height));
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 22px 65px rgba(0, 0, 0, .3);
}
.user-chat-panel[hidden],
.user-chat-badge[hidden],
.user-chat-turnstile[hidden],
.user-chat-emojis[hidden] { display: none !important; }
.user-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.user-chat-title { font-weight: 750; }
.user-chat-status { margin-top: 3px; color: var(--muted); font-size: .76rem; }
.user-chat-close { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--bg); color: var(--text); font-size: 1.25rem; cursor: pointer; }
.user-chat-retention { padding: 7px 14px; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); color: var(--muted); font-size: .74rem; text-align: center; }
.user-chat-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 14px; background: var(--bg); }
.user-chat-empty { padding: 38px 18px; color: var(--muted); text-align: center; line-height: 1.75; }
.user-chat-row { display: flex; margin: 8px 0; }
.user-chat-row.is-me { justify-content: flex-end; }
.user-chat-message { max-width: 84%; }
.user-chat-message-time { margin: 0 4px 3px; color: var(--muted); font-size: .67rem; }
.user-chat-row.is-me .user-chat-message-time { text-align: right; }
.user-chat-bubble { width: fit-content; max-width: 100%; min-width: 0; padding: 9px; border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; background: var(--surface); line-height: 1.5; overflow-wrap: anywhere; text-align: center; white-space: pre-wrap; }
.user-chat-row.is-me .user-chat-bubble { margin-left: auto; border-color: transparent; border-radius: 12px 12px 4px; background: var(--accent); color: #fff; }
.user-chat-turnstile { padding: 8px 12px 0; overflow-x: auto; }
.user-chat-compose-wrap { position: relative; flex: 0 0 auto; }
.user-chat-compose { border-top: 1px solid var(--border); }
.user-chat-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px 12px 0; }
.user-chat-emoji-toggle { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 1.3rem; cursor: pointer; }
.user-chat-emoji-toggle:disabled { cursor: default; opacity: .55; }
.user-chat-limit { color: var(--muted); font-size: .7rem; }
.user-chat-emojis { position: absolute; right: 12px; bottom: calc(100% + 8px); z-index: 3; display: flex; width: min(360px, calc(100% - 24px)); max-height: min(228px, 45vh); flex-wrap: wrap; gap: 6px; padding: 8px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 34px rgba(0, 0, 0, .24); }
.user-chat-emojis button { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 1.25rem; line-height: 1; cursor: pointer; touch-action: manipulation; }
.user-chat-compose-row { display: flex; align-items: flex-end; gap: 8px; padding: 9px 12px 12px; }
.user-chat-compose textarea { height: 48px; min-height: 48px; max-height: 105px; flex: 1; resize: none; overflow-y: hidden; overscroll-behavior: contain; }
.user-chat-compose .btn { width: auto; min-width: 62px; height: 48px; flex: 0 0 auto; align-self: flex-end; }
@media (max-width: 600px) {
  .user-chat-launcher { right: 16px; bottom: 16px; }
  .user-chat-panel { top: var(--user-chat-top-boundary); right: 0; bottom: 0; left: 0; width: 100%; height: auto; max-height: none; min-height: 0; border: 0; border-radius: 0; }
  .user-chat-message { max-width: 90%; }
}
