/* ---- live chat ---- */
.header-right { display: flex; align-items: center; gap: 10px; }
.chat-icon { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-toggle { position: relative; display: flex; align-items: center; gap: 8px; }
body.chat-open .chat-toggle { border-color: var(--accent); }
.chat-unread { position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 2px solid var(--panel); }

#chat { display: none; position: fixed; top: 64px; right: 0; bottom: 0; z-index: 6; width: min(320px, 100vw); flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0, 0, 0, .3); }
body.chat-open #chat { display: flex; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head .chat-icon { color: var(--accent); }
.chat-head b { flex: 1; }
.chat-admin-link { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; }
.chat-hide { background: transparent; border: 0; padding: 0 6px; font-size: 24px; line-height: 1; color: var(--muted); }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 0; }
.chat-empty { text-align: center; padding: 24px 12px; }
.chat-msg { position: relative; padding: 6px 14px; }
.chat-msg:hover { background: rgba(255, 255, 255, .03); }
.chat-msg.called { background: rgba(34, 221, 39, .09); box-shadow: inset 3px 0 0 var(--accent); }
.chat-quote { margin: 0 0 3px 38px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row { display: flex; align-items: flex-start; gap: 10px; }
.chat-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; margin-top: 3px; overflow: hidden; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; font-weight: 700; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-body { flex: 1; min-width: 0; }
.chat-meta { display: flex; align-items: baseline; gap: 6px; }
.chat-meta .chat-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: transparent; border: 0; padding: 0; font-weight: 700; font-size: 13.5px; }
.chat-meta time { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
.chat-badge { flex: 0 0 auto; font-size: 9px; font-weight: 800; letter-spacing: .06em; color: var(--on-accent); background: var(--accent); border-radius: 4px; padding: 1px 5px; }
.chat-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; color: #d3e3d7; }
.chat-mention { color: var(--accent-2); background: var(--selected); border-radius: 4px; padding: 0 4px; font-weight: 600; }
.chat-tools { position: absolute; top: 2px; right: 8px; display: none; gap: 3px; }
.chat-msg:hover .chat-tools, .chat-msg:focus-within .chat-tools { display: flex; }
.chat-tools button { padding: 0 7px; font-size: 12px; line-height: 22px; }
.chat-msg:focus { outline: none; }

.chat-replying { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 10px; padding: 4px 10px; font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 8px 8px 0 0; }
.chat-replying button { background: transparent; border: 0; padding: 0 4px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input { flex: 1; min-width: 0; }
.chat-input:disabled { opacity: .6; }
button.chat-send { flex: 0 0 auto; display: grid; place-items: center; width: 44px; padding: 0; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chat-foot { display: flex; align-items: center; gap: 8px; padding: 0 14px 10px; font-size: 12px; color: var(--muted); }
.chat-online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* On wide screens the chat sits beside the page instead of covering it. */
@media (min-width: 1280px) {
  body.chat-open main { margin-left: max(210px, calc((100vw - 320px - 1150px) / 2 + 105px)); max-width: min(1150px, calc(100vw - 530px)); }
  body.chat-open .actionbar { right: 320px; }
}
@media (max-width: 600px) {
  .chat-toggle span { display: none; }
  .chat-toggle { padding: 8px 10px; }
}

/* ---- chat admin page ---- */
.admin { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }
.admin .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-top: 16px; }
.admin h2 { margin: 0 0 12px; }
.admin .line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin .line input { width: auto; flex: 0 1 180px; }
.admin .list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 460px; overflow-y: auto; }
.admin .entry-text { min-width: 0; overflow-wrap: anywhere; }
.admin .entry > .buttons { flex-direction: row; flex-shrink: 0; }
.admin label.line { flex-wrap: nowrap; white-space: nowrap; }
.admin .on { color: var(--green); font-weight: 700; }
.admin .off { color: var(--red); font-weight: 700; }
