.chat-msg .when { white-space: nowrap; }

.chat-msg .meta { align-items: center; }

.chat-reply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 24px;
  background: rgba(138, 123, 255, 0.1);
  border: 1px solid rgba(138, 123, 255, 0.28);
  color: var(--void-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 999px;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.chat-reply-btn .ic { font-size: 0.85rem; }
.chat-reply-btn:hover { opacity: 1; background: rgba(138, 123, 255, 0.22); }
.chat-reply-btn:focus-visible {
  opacity: 1;
  background: rgba(138, 123, 255, 0.22);
  outline: 2px solid var(--gold-soft);
  outline-offset: 1px;
}

.chat-del {
  min-height: 24px;
  font-size: 0.7rem;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 107, 107, 0.3);
  opacity: 0.7;
}
.chat-del:hover { opacity: 1; background: rgba(255, 107, 107, 0.14); }
.chat-del:focus-visible { opacity: 1; outline: 2px solid var(--gold-soft); outline-offset: 1px; }

.chat-quote {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  border: 0;
  border-left: 3px solid var(--gold);
  background: rgba(243, 195, 74, 0.07);
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.chat-quote:hover { background: rgba(243, 195, 74, 0.15); }
.chat-quote:focus-visible { background: rgba(243, 195, 74, 0.15); outline: 2px solid var(--gold-soft); outline-offset: 1px; }
.chat-quote:disabled { cursor: default; opacity: 0.7; }
.chat-quote-icon { color: var(--gold); font-size: 0.9rem; flex-shrink: 0; }
.chat-quote-text {
  display: flex;
  gap: 6px;
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-quote-user { color: var(--gold-soft); font-weight: 600; flex-shrink: 0; }
.chat-quote-body { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.chat-msg.mine .chat-quote {
  border-left: 0;
  border-right: 3px solid var(--void);
  background: rgba(138, 123, 255, 0.1);
}
.chat-msg.mine .chat-quote:hover { background: rgba(138, 123, 255, 0.18); }

.chat-msg.replying .bubble {
  box-shadow: 0 0 0 2px var(--gold-soft);
}

.chat-reply {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--gold);
  background: var(--panel-solid);
  border-radius: 10px 10px 0 0;
  border-bottom: 0;
  margin-bottom: -1px;
}
.chat-reply-icon {
  color: var(--gold);
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}
.chat-reply-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-reply-head { font-size: 0.78rem; color: var(--gold-soft); }
.chat-reply-head strong { color: var(--gold); }
.chat-reply-excerpt {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-reply-cancel {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
  min-width: 24px;
  min-height: 24px;
  padding: 4px 6px;
  border-radius: 6px;
}
.chat-reply-cancel:hover { color: var(--ink); background: var(--line); }
.chat-reply-cancel:focus-visible { color: var(--ink); outline: 2px solid var(--gold-soft); outline-offset: 1px; }

.chat-toast {
  position: sticky;
  bottom: 8px;
  align-self: center;
  max-width: 90%;
  margin: 4px auto 0;
  padding: 8px 14px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.chat-toast.show { opacity: 1; transform: translateY(0); }

.chat-msg.flash .bubble { animation: chatFlash 1.2s ease; }
@keyframes chatFlash {
  0% { box-shadow: 0 0 0 2px var(--gold); }
  100% { box-shadow: 0 0 0 0 rgba(243, 195, 74, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-msg.flash .bubble { animation: none; box-shadow: 0 0 0 2px var(--gold); }
  .chat-toast { transition: none; }
}
