/* old-like message surface; .oldMessageRow is the current renderer alias. */
:where(.oldMsgRow, .oldMessageRow) {
  /* fix: 2026-05-27 - use brighter old-like metadata tokens on dark cards. */
  --old-msg-text: var(--chat-text, rgba(245, 248, 255, 0.96));
  --old-msg-muted: rgba(232, 240, 255, 0.92);
  --old-msg-faint: rgba(216, 228, 252, 0.88);
  --old-user-strip: color-mix(in srgb, var(--chat-user-bubble, #eef3ff) 18%, transparent);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--old-msg-text);
}

:where(.oldMsgRow, .oldMessageRow).user { justify-content: flex-start; }

:where(.oldMsgRow, .oldMessageRow).system {
  gap: 8px;
  color: var(--old-msg-muted);
  font-size: 12px;
  line-height: 1.45;
}

:where(.oldMsgRow, .oldMessageRow) :is(.msgAvatarSlot, .oldMsgAvatar) {
  /* fix: 2026-05-27 - stabilize legacy avatar box sizing and clipping. */
  position: relative;
  box-sizing: border-box;
  order: 0;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  margin: 0;
  border-radius: 999px;
  overflow: hidden;
}

:where(.oldMsgRow, .oldMessageRow).user .msgAvatarSlot { order: 0; }

:where(.oldMsgRow, .oldMessageRow) :is(.msgAvatarSlot img, .msgAvatarImg, .oldMsgAvatar img) {
  /* fix: 2026-05-27 - prevent stretched or offset legacy avatars. */
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
}

:where(.oldMsgRow, .oldMessageRow) :is(.oldMessageMain, .oldMsgBlock) {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

:where(.oldMsgRow, .oldMessageRow).user :is(.oldMessageMain, .oldMsgBlock) {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--old-user-strip);
}

:where(.oldMsgRow, .oldMessageRow).system :is(.oldMessageMain, .oldMsgBlock) {
  padding: 2px 0;
  background: transparent;
}

:where(.oldMsgRow, .oldMessageRow) :is(.oldMessageHead, .oldMsgIdentity) {
  /* fix: 2026-05-27 - make old-like identity rows readable on translucent backgrounds. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin: 0 0 4px;
}

:where(.oldMsgRow, .oldMessageRow) .oldMessageIdentity {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

:where(.oldMsgRow, .oldMessageRow) :is(.oldMessageRole, .oldMsgName) {
  min-width: 0;
  overflow: hidden;
  color: var(--old-msg-text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(.oldMsgRow, .oldMessageRow) .oldMessageMeta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  color: var(--old-msg-faint);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

:where(.oldMsgRow, .oldMessageRow) :is(.msgTime, .oldMsgTime) {
  color: var(--old-msg-faint);
  font-size: 11px;
  font-weight: 700;
}

:where(.oldMsgRow, .oldMessageRow) :is(.oldMessageBody, .oldMsgText) {
  width: 100%;
  min-width: 0;
}

:where(.oldMsgRow, .oldMessageRow) .bubbleText {
  width: 100%;
  max-width: 100%;
  color: inherit;
  font-size: var(--chat-message-font-size, 16px);
  line-height: var(--chat-message-line-height, 1.66);
}

:where(.oldMsgRow, .oldMessageRow) :is(.msgToolWrap, .oldMsgButtons) {
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 140ms ease;
}

:where(.oldMsgRow, .oldMessageRow):is(:hover, :focus-within) :is(.msgToolWrap, .oldMsgButtons),
:where(.oldMsgRow, .oldMessageRow) .msgToolWrap:is(.expanded, .editing) { opacity: 1; }

:where(.oldMsgRow, .oldMessageRow).system :is(.msgAvatarSlot, .oldMsgAvatar, .oldMessageHead) { display: none; }

:where(.oldMsgRow, .oldMessageRow).system .bubbleText {
  color: var(--old-msg-muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (hover: none) {
  :where(.oldMsgRow, .oldMessageRow) :is(.msgToolWrap, .oldMsgButtons) { opacity: 1; }
}

@media (max-width: 560px) {
  :where(.oldMsgRow, .oldMessageRow) { gap: 10px; }
  :where(.oldMsgRow, .oldMessageRow) :is(.oldMessageHead, .oldMsgIdentity) { align-items: flex-start; }
}

/* 20260526 old-like layout authority: compact SillyTavern-like transcript,
   small square avatars, no bubbles, alternating row wash only. */
.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) {
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow):nth-child(even) {
  background: color-mix(in srgb, var(--chat-surface) 20%, transparent);
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) :is(.msgAvatarSlot, .oldMsgAvatar) {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) :is(.oldMessageMain, .oldMsgBlock) {
  padding: 0 !important;
  background: transparent !important;
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) :is(.oldMessageHead, .oldMsgIdentity) {
  margin-bottom: 2px;
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) :is(.oldMessageRole, .oldMsgName) {
  font-size: 12px;
}

.chatRoom.presentation-classic :where(.oldMsgRow, .oldMessageRow) .bubbleText {
  font-size: 14px;
  line-height: 1.52;
}
