/* Chat sizing is deliberately independent of the general form styles. */
.chat-panel[hidden],.chat-user-menu[hidden],.chat-conversations[hidden],.unread-dot[hidden]{display:none}
.chat-panel{
  --chat-composer-max:120px;
  position:fixed;
  right:26px;
  bottom:86px;
  width:min(460px,calc(100vw - 32px));
  height:min(720px,calc(100dvh - 166px));
  max-height:calc(100dvh - 166px);
  border-radius:20px;
  z-index:110;
  isolation:isolate;
}
.chat-toggle{z-index:110}
.chat-panel,.chat-panel>header,.chat-conversations,.chat-panel>form,.chat-messages{box-sizing:border-box;min-width:0}
.chat-panel>header{flex:none;gap:12px;padding:12px 16px;background:var(--surface)}
.chat-panel>header>div{min-width:0;flex:1}
.chat-panel [data-chat-title]{display:block;font-size:16px;line-height:26px;overflow-wrap:anywhere}
.chat-panel>header small{display:block;max-width:none;font-size:12px;line-height:1.4;margin-top:2px;color:var(--muted)}
.chat-panel>header>.icon-btn{width:40px;min-width:40px;height:40px;align-self:flex-start;font-size:22px}
.chat-conversations{padding:0;border:0;min-width:0}
.chat-conversations select{
  display:block;width:100%;min-width:0;max-width:100%;height:34px;min-height:34px;
  padding:3px 28px 3px 7px;margin-left:-7px;border-color:transparent;border-radius:7px;
  font-size:16px;font-weight:650;line-height:1.4;background:var(--surface);text-overflow:ellipsis;
}
.chat-conversations select:hover{border-color:var(--line);background:var(--soft)}
.chat-messages{flex:1;min-height:0;overflow:auto;overflow-x:hidden;padding:18px 20px;scrollbar-gutter:stable;overflow-anchor:none;overscroll-behavior:contain}
.chat-message{max-width:100%;min-width:0;margin:0 0 20px;font-size:14px;line-height:1.5}
.chat-message:last-child{margin-bottom:0}
.chat-message header{display:flex;align-items:center;flex-wrap:wrap;gap:5px 7px;white-space:normal;line-height:1.4}
.chat-message header strong,.chat-message header button{font-size:12px;line-height:1.4}
.chat-message header button{background:none;border:0;color:var(--ink);padding:3px 2px}
.chat-message .chat-author{font-weight:650;color:var(--green);text-align:left;overflow-wrap:anywhere;max-width:100%}
.chat-message time{margin-left:auto;font-size:11px;line-height:1.4;color:var(--muted)}
.chat-message.own header{justify-content:flex-end}
.chat-message.own time{margin-left:0}
.chat-message p{max-width:94%;box-sizing:border-box;overflow-wrap:anywhere;margin-top:6px;padding:10px 13px;border-radius:12px;text-align:left}
.chat-message small{margin:4px 0 0;font-size:11px}
.chat-message [data-chat-action=delete]{color:var(--muted);width:24px;min-height:24px;margin-left:0;border-radius:6px;font-size:16px}
.chat-message [data-chat-action=delete]:hover{background:var(--soft);color:var(--red)}
.chat-presence{width:6px;height:6px;flex:none;border-radius:50%;background:#b47870}
.chat-presence.online{background:#42976d}
.chat-empty{font-size:14px;line-height:1.6;text-align:center;padding:24px 10px}
.chat-status{flex:none;font-size:12px;line-height:1.5;color:var(--muted);padding:0 16px;margin:0;overflow-wrap:anywhere}
.chat-status:not(:empty){padding:8px 16px}
.chat-panel>form{flex:none;display:flex;flex-wrap:nowrap;align-items:flex-end;gap:10px;padding:12px;border-top:1px solid var(--line);background:var(--surface)}
.chat-panel>form textarea{
  flex:1;box-sizing:border-box;width:0;min-width:0;max-width:100%;height:44px;min-height:44px;
  max-height:var(--chat-composer-max);resize:none;overflow-y:auto;overscroll-behavior:contain;
  padding:10px 12px;font-size:14px;line-height:22px;border-radius:12px;
}
.chat-panel>form>.icon-btn{flex:none;width:44px;min-width:44px;height:44px;background:var(--green);color:var(--surface);border-radius:12px}
.chat-panel>form>.icon-btn:hover{filter:brightness(1.08)}
.chat-panel :focus-visible{outline:2px solid var(--green);outline-offset:2px}
.chat-user-menu{position:fixed;z-index:120;display:grid;padding:6px;width:205px;max-width:calc(100vw - 16px);border:1px solid var(--line);border-radius:13px;box-shadow:0 14px 45px #0003;background:var(--surface);color:var(--ink)}
.chat-user-menu>button,.chat-user-menu>a{display:block;text-align:left;padding:11px;border:0;border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13px;text-decoration:none}
.chat-user-menu>:hover,.chat-user-menu>:focus-visible{background:var(--soft);outline:2px solid var(--green);outline-offset:-2px}
.chat-report-dialog blockquote{margin:14px 0;border-left:3px solid var(--green);padding:10px 14px;background:var(--soft);max-height:140px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere}
.chat-report-dialog .form-grid>p{font-size:12px}
.chat-report-dialog textarea{resize:vertical}
.chat-report-dialog [role=status]:empty{display:none}
@media(max-height:540px){.chat-panel{--chat-composer-max:80px}}
/* Preserve the production visual-viewport fix, including mobile keyboards. */
@media(max-width:680px),(max-height:540px){
  .chat-panel{
    left:8px;right:8px;width:auto;max-width:calc(100% - 16px);
    top:calc(var(--chat-viewport-top,0px) + 8px + env(safe-area-inset-top,0px));bottom:auto;
    height:calc(var(--chat-viewport-height,100dvh) - 16px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
    max-height:none;border-radius:14px;
  }
  .chat-panel>header{padding:10px 12px}
  .chat-panel>header>.icon-btn{flex:none;min-width:44px;min-height:44px}
  .chat-panel>form{padding:10px;gap:8px}
  .chat-panel>form textarea,.chat-conversations select,.chat-report-dialog textarea,.chat-report-dialog select{font-size:16px;line-height:1.4}
  .chat-panel:not([hidden])~.chat-toggle{display:none}
  .chat-messages{padding:14px 12px}
  .chat-message p{max-width:100%}
  .chat-message time{font-size:11px}
  .chat-report-dialog{box-sizing:border-box;max-width:calc(100% - 16px);max-height:calc(var(--chat-viewport-height,100dvh) - 16px);overflow:auto}
}
