/* Private messages (Pages/Messages, Pages/Account/Messages): the inbox, a conversation, the
   new-message form, the profile's buttons. Variables from site.css only: no color, shadow
   or font is named here. Mobile first: the base is a phone, min-width queries add to it. */

/* A conversation and the small forms keep a narrow column. The inbox is a list: it has
   no msg-page and uses the full width, like every list page (CLAUDE.md, "Breadcrumbs
   and page tops"). */
.msg-page { max-width: 860px; width: 100%; margin-left: auto; margin-right: auto; }
.msg-nav-link { display: inline-flex; align-items: center; gap: 8px; }

/* ---- The inbox ---- */
.conv-list { margin: 0; padding: 0; list-style: none; }
.conv-row { border-top: 1px solid var(--line-soft); transition: background-color var(--ease); }
.conv-row:first-child { border-top: 0; }
.conv-row:hover, .conv-row.unread { background: var(--surface-alt); }
.conv-link { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 12px 16px; color: var(--ink); text-decoration: none; }
.conv-link:focus-visible { outline-offset: -2px; }
.conv-link .notif-dot { margin-top: 15px; }
.conv-row.unread .notif-dot { border-color: var(--unread); background: var(--unread); box-shadow: var(--unread-glow); }
.conv-link .avatar { flex: none; }
.conv-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.conv-subject { font-size: 16px; }
a.conv-link:hover .conv-subject { text-decoration: underline; }
.conv-row.unread .conv-subject { font-weight: 700; }
.conv-with { color: var(--ink); font-size: 14px; }
.conv-meta { color: var(--muted); font-size: 13px; }
/* From tablet width the count and the time sit at the right of the row, as on a thread
   row, and the subject is held to a readable length instead of crossing the page. */
@media (min-width: 768px) {
  .conv-text { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 24px; }
  .conv-subject, .conv-with { grid-column: 1; max-width: 72ch; }
  .conv-meta { grid-column: 2; grid-row: 1 / span 2; max-width: 22em; text-align: right; }
}

/* ---- A conversation, as a chat (Conversation.cshtml, ChatLayout, js/chat.js) ----
   Messages one person sent in a row share a name and a small avatar. Yours are on the
   right on --band with an accent-tinted border; other people's on the left on --surface:
   side and shade both say whose it is, never color alone. Text in a bubble is the post's
   own, so a bubble is only ever a ground the theme's text is checked on (--surface,
   --band; ThemeContrast). Dates and "New messages" are lines across the page. */
.msg-people { display: flex; flex-wrap: wrap; gap: 0 6px; overflow-wrap: anywhere; }
.msg-people a { color: var(--accent); }
.msg-head-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.chat { display: flex; flex-direction: column; gap: 10px; }

/* A date, or where the new messages start: words in the middle of a line. */
.chat-line {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 0;
  color: var(--muted); font-family: var(--font); font-size: 13px; font-weight: 600; line-height: 1.4; letter-spacing: 0;
}
.chat-line::before, .chat-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chat-new { color: var(--unread); scroll-margin-top: calc(var(--sticky-top, 0px) + 12px); }
.chat-new::before, .chat-new::after { background: var(--unread); }

.chat-group { display: flex; align-items: flex-start; gap: 8px; }
.chat-group.mine { justify-content: flex-end; }
.chat-group > .avatar { flex: none; margin-top: 2px; }
.chat-run { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.chat-group.mine .chat-run { align-items: flex-end; }
.chat-who { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-bottom: 2px; padding: 0 4px; }
.chat-by { margin: 0; font-family: var(--font); font-size: 14px; font-weight: 700; line-height: 1.4; letter-spacing: 0; overflow-wrap: anywhere; }
.chat-by a { color: var(--ink); text-decoration: none; }
.chat-by a:hover { text-decoration: underline; }
.chat-group.mine .chat-by { color: var(--muted); font-weight: 600; }
.chat-who .role-chip, .chat-who .card-badge { font-size: 12px; }

/* One message: its bubble, and beside it the button that opens its actions. */
.chat-msg { display: flex; align-items: flex-start; gap: 2px; max-width: 100%; min-width: 0; scroll-margin-top: calc(var(--sticky-top, 0px) + 12px); }
.chat-group.mine .chat-msg { flex-direction: row-reverse; }
.chat-bubble {
  min-width: 0; min-height: 44px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 0 14px;
  padding: 10px 14px; border: 1px solid var(--card-line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--elev-1); overflow-wrap: anywhere;
}
.chat-group.mine .chat-bubble { border-color: var(--accent-line); background: var(--band); box-shadow: none; }
.chat-msg:target .chat-bubble { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.chat-bubble .msg-body { flex: 1 1 auto; min-width: 0; margin: 0; }
/* Something wide (a table, a player, a file's card) gets the bubble's whole width. */
.chat-bubble .msg-body:has(table, pre, iframe, video, audio, .rf-file, .rf-embed, figure) { flex-basis: 100%; }
/* The time sits at the end of a short message's own line, and under a long one. */
.chat-meta { flex: none; margin: 0 0 0 auto; color: var(--muted); font-size: 12px; line-height: 22px; white-space: nowrap; }
/* A quote, code and a table's heading are drawn on --band or --ground in a post. On your
   own bubble, which is --band, they go on --surface so they still show. */
.chat-group.mine .md-post :is(blockquote, code, pre),
.chat-group.mine .rf-post :is(.rf-quote, pre, th, :not(pre) > code) { background: var(--surface); }
.chat-group.mine :is(.md-post, .rf-post) pre code { background: none; }
.chat-edited { font-style: italic; }
.msg-deleted { color: var(--muted); font-style: italic; }
.chat-msg.is-deleted .chat-bubble, .chat-group.mine .chat-msg.is-deleted .chat-bubble {
  border-style: dashed; border-color: var(--control-line); background: none; box-shadow: none;
}

/* A message's actions: Edit and Delete on your own, Report on somebody else's. A details
   element, so it opens by touch and keyboard with scripts off; chat.js closes it on a
   press elsewhere and on Escape. */
.chat-more { position: relative; flex: none; }
.chat-more > summary {
  display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: var(--radius-round); color: var(--muted); cursor: pointer; list-style: none;
}
.chat-more > summary::-webkit-details-marker { display: none; }
.chat-more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.chat-more[open] > summary { color: var(--ink); background: var(--band); }
.chat-more-panel {
  position: absolute; top: 44px; right: 0; z-index: 10; min-width: 150px; display: flex; flex-direction: column; padding: 6px;
  border: 1px solid var(--card-line); border-radius: var(--radius-small); background: var(--surface-raised); box-shadow: var(--elev-3);
}
.chat-group.mine .chat-more-panel { right: auto; left: 0; }
.chat-more-panel a {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius-chip);
  color: var(--ink); font-size: 15px; font-weight: 500; text-decoration: none;
}
.chat-more-panel a:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  /* With a mouse the button waits until its message is pointed at; the keyboard always finds it. */
  .chat-more { opacity: 0; transition: opacity var(--ease); }
  .chat-msg:hover .chat-more, .chat-more:focus-within, .chat-more[open] { opacity: 1; }
  .chat-more > summary:hover { color: var(--ink); background: var(--band); }
  .chat-more-panel a:hover { background: var(--band); }
}

.msg-quoted { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface-alt); }
/* The reported messages under the reported posts on /mod. */
.mod-subtitle { margin-top: 28px; font-size: 22px; }
.msg-page .compose { margin-top: 16px; }

/* ---- Leaving ---- */
.msg-confirm { padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.msg-confirm p { margin: 0; }
.msg-confirm-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---- A profile's buttons, and the blocked list ---- */
.msg-profile-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-profile-buttons form { margin: 0; }
.msg-blocked { margin: 0; padding: 0; list-style: none; }
.msg-blocked li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 52px; border-top: 1px solid var(--line-soft); overflow-wrap: anywhere; }
.msg-blocked li:first-child { border-top: 0; }
.msg-blocked form { margin: 0; }
.msg-blocked a { color: var(--accent); }

@media (min-width: 768px) {
  .conv-link { padding: 14px 20px; }
  /* Room beside a bubble, so a long message does not run the width of the page. */
  .chat-run { max-width: 78%; }
  .msg-confirm { padding: 24px; }
}
