#chat {
  position: fixed;
  right: 20px;
  bottom: calc(var(--dock-bottom) + 90px);
  z-index: 25;
  display: none;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  height: min(60vh, 480px);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: pop .2s ease both;
}

body.chat-open.joined #chat {
  display: flex;
}

#chatList {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  line-height: 1.4;
}

#chatList:empty::before {
  content: "…";
  margin: auto;
  color: var(--muted);
}

.msg {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.msg .who {
  flex: none;
  min-width: 2ch;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .03em;
  cursor: default;
}

.msg .text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.gap {
  align-self: center;
  margin: 4px 0;
  font-size: 12px;
  color: var(--muted);
}

#chatForm {
  display: flex;
  gap: 8px;
  align-items: center;
}

#chatInput {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

#chatInput:disabled {
  opacity: .5;
}

#chatToggle.unread::before {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px var(--bg);
}
