.site-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #111;
  box-shadow: 0 8px 28px rgba(255, 107, 0, .35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
}

.site-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(255, 107, 0, .45);
}

.site-chat-launcher .icon {
  width: 26px;
  height: 26px;
}

.site-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 88px;
  z-index: 1199;
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .18s, transform .18s, visibility .18s;
}

.site-chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.site-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, .18);
}

.site-chat-head-main {
  min-width: 0;
}

.site-chat-title {
  margin: 0;
  color: var(--bright);
  font: 600 14px/1.2 var(--font);
}

.site-chat-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.site-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.site-chat-tg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 107, 0, .35);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px var(--font);
  text-decoration: none;
  white-space: nowrap;
}

.site-chat-tg:hover {
  color: var(--bright);
  border-color: var(--accent);
}

.site-chat-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.site-chat-close:hover {
  color: var(--bright);
}

.site-chat-messages {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.site-chat-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.site-chat-msg {
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 4px;
  background: rgba(0, 0, 0, .22);
}

.site-chat-msg.own {
  align-self: flex-end;
  border-color: rgba(255, 107, 0, .28);
  background: rgba(255, 107, 0, .12);
  border-radius: 12px 12px 4px 12px;
}

.site-chat-msg.tg {
  border-color: rgba(54, 211, 153, .22);
}

.site-chat-msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.site-chat-msg-nick {
  color: var(--accent);
  font: 600 12px var(--font);
}

.site-chat-msg.tg .site-chat-msg-nick {
  color: var(--ok);
}

.site-chat-msg-time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.site-chat-msg-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.site-chat-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, .12);
}

.site-chat-tg-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  font-size: 13px;
  text-decoration: none;
}

.site-chat-readonly .site-chat-messages {
  min-height: 280px;
}

.site-chat-nick {
  width: 100%;
  margin-bottom: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0d1218;
  color: var(--bright);
  font: 13px var(--font);
  outline: none;
}

.site-chat-nick:focus {
  border-color: var(--accent);
}

.site-chat-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.site-chat-input {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0d1218;
  color: var(--bright);
  font: 13px/1.35 var(--font);
  outline: none;
}

.site-chat-input:focus {
  border-color: var(--accent);
}

.site-chat-send {
  min-width: 72px;
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #111;
  font: 600 12px var(--font);
  cursor: pointer;
}

.site-chat-send:disabled {
  opacity: .55;
  cursor: default;
}

.site-chat-error {
  margin: 8px 0 0;
  color: var(--bad);
  font-size: 12px;
  min-height: 16px;
}

@media (max-width: 760px) {
  .site-chat-launcher {
    right: 16px;
    bottom: 16px;
  }

  .site-chat-panel {
    right: 16px;
    bottom: 80px;
    width: calc(100vw - 32px);
  }
}
