/* Direct messages (2026-11-20; messages.js builds everything here but the header button).
   The header's Messages button and its list; a conversation as a window docked bottom right (several side by
   side on a wide screen); a minimised conversation as a round bubble in the corner; on a phone the list and a
   conversation fill the screen instead.
   The site dialogs' look: the raised dark panel, hairline borders, quiet rows. Colour only where it says
   something: the unread count, your own messages, the send button.
   Stacking: above the page, its header (100) and its toasts (300); under the site dialogs (2000), so a profile
   opens over a conversation. Nothing here shows inside a fullscreen picture. */

/* ---------- the header button ---------- */
.msgBtn { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 36px; padding: 0; color: var(--silver-1); background: linear-gradient(180deg, #1b1b20, #141418); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.msgBtn svg { width: 19px; height: 19px; display: block; }
.msgBtn:hover, .msgBtn.isOpen { background: linear-gradient(180deg, #222229, #18181d); border-color: rgba(255, 255, 255, 0.16); }
.msgBtn.isOpen { border-color: rgba(255, 255, 255, 0.28); }
.msgBtn:focus-visible { outline: 2px solid var(--silver-2); outline-offset: 2px; }
.msgBadge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; line-height: 1; color: #fff; background: var(--red); border-radius: 999px; box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }
/* The header bar's own copy, where the account buttons are inside the menu button (as the Upload button does). */
.msgBtnMobile { display: none; }
@media (max-width: 1450px) {
	.msgBtnMobile { display: inline-flex; height: 38px; }
	.userMenu .msgBtn { display: none; }
}

/* ---------- shared pieces ---------- */
.msgRoot { font-size: 14px; line-height: 1.4; color: var(--fg); }
.msgAv { position: relative; display: inline-block; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--bg-elev-2); box-shadow: 0 0 0 1px var(--line); }
.msgAv img { width: 100%; height: 100%; display: block; box-sizing: border-box; padding: 16%; border-radius: 50%; object-fit: contain; }
.msgAv img.isCover { padding: 0; object-fit: cover; }
.msgAv img:not([src]), .msgAv img[src=""] { visibility: hidden; }
/* Online: a green dot on the picture's corner. */
.msgAv.isOn::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 26%; height: 26%; min-width: 9px; min-height: 9px; border-radius: 50%; background: #37c46a; box-shadow: 0 0 0 2px var(--bg-elev); }
.msgIconBtn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0; color: var(--fg-dim); background: none; border: 0; border-radius: 6px; cursor: pointer; transition: background 0.1s, color 0.1s; }
.msgIconBtn svg { width: 18px; height: 18px; display: block; }
.msgIconBtn:hover { color: var(--silver-1); background: var(--bg-elev-2); }
.msgIconBtn:focus-visible { outline: 2px solid var(--silver-2); outline-offset: 1px; }

/* ---------- the list ---------- */
.msgPanel { position: fixed; z-index: 450; top: 68px; right: 16px; width: 372px; max-width: calc(100% - 16px); max-height: calc(100% - 96px); display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.62), 0 2px 6px rgba(0, 0, 0, 0.4); overflow: hidden; }
.msgPanelHead { display: flex; align-items: center; justify-content: space-between; flex: none; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--line-soft); }
.msgPanelTitle { margin: 0; font-size: 17px; font-weight: 700; color: var(--silver-1); }
.msgList { flex: 1 1 auto; min-height: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #33333b transparent; }
.msgRow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; color: var(--fg); font: inherit; text-align: left; background: none; border: 0; border-radius: 8px; cursor: pointer; transition: background 0.1s; }
.msgRow:hover, .msgRow:focus-visible { background: var(--bg-elev-2); outline: none; }
.msgRowText { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.msgRowName { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 14px; font-weight: 500; color: var(--silver-1); }
.msgRowNameText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgRowName .supporterTag { flex: none; font-size: 10px; padding: 0 7px; }
.msgRowLast { font-size: 12.5px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgRowMeta { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 26px; }
.msgRowTime { font-size: 11.5px; color: var(--fg-mute); }
.msgRowDot { width: 9px; height: 9px; border-radius: 50%; background: var(--red-bright); }
/* Something unread: the name and the last line come forward. */
.msgRow.isUnread .msgRowName { font-weight: 700; color: #fff; }
.msgRow.isUnread .msgRowLast { color: var(--fg); font-weight: 500; }
.msgRow.isUnread .msgRowTime { color: var(--fg-dim); }
/* "Message Metal TV": set off from the conversations by a rule. */
.msgRow.isSupport { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; }
.msgRow.isSupport:first-child { margin-top: 0; border-top: 0; padding-top: 8px; border-radius: 8px; }
.msgListNote { padding: 26px 22px 24px; font-size: 13px; line-height: 1.5; color: var(--fg-mute); text-align: center; }
.msgListNoteTitle { margin-bottom: 4px; font-size: 14.5px; font-weight: 600; color: var(--fg-dim); }

/* ---------- conversations, docked bottom right ---------- */
/* The dock spans the window's height only so a window's max-height can be a share of it; it takes no clicks. */
.msgDock { position: fixed; z-index: 400; top: 0; bottom: 0; right: 16px; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 12px; pointer-events: none; }
.msgRoot.hasChips .msgDock { right: 84px; }   /* the bubbles keep the corner */
.msgWin { position: relative; display: flex; flex-direction: column; width: 336px; height: 460px; max-height: calc(100% - 92px); pointer-events: auto; background: var(--bg-elev); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.3); }
.msgWinHead { display: flex; align-items: center; gap: 2px; flex: none; padding: 7px 6px 7px 8px; border-bottom: 1px solid var(--line-soft); border-radius: 10px 10px 0 0; }
.msgWinWho { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 3px 6px 3px 3px; color: inherit; font: inherit; text-align: left; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.msgWinWho:hover { background: var(--bg-elev-2); }
.msgWinWho:focus-visible { outline: 2px solid var(--silver-2); outline-offset: 1px; }
.msgWinWho .msgAv { width: 34px; height: 34px; }
.msgWinNames { min-width: 0; display: flex; flex-direction: column; }
.msgWinName { font-size: 14px; font-weight: 600; color: var(--silver-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgWinStatus { font-size: 11.5px; color: var(--fg-mute); }
.msgBack { display: none; }
/* Something unread in a window the viewer has not looked at yet: a red line along its top. */
.msgWin.hasUnread { border-top-color: var(--red); box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.55), inset 0 2px 0 var(--red); }
.msgWin.hasUnread .msgWinName { color: #fff; }

.msgMenu { position: absolute; z-index: 3; top: 46px; right: 40px; min-width: 168px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.6); }
.msgMenuItem { display: block; width: 100%; padding: 8px 10px; color: var(--fg); font: inherit; font-size: 13.5px; text-align: left; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.msgMenuItem:hover, .msgMenuItem:focus-visible { background: var(--bg-elev-2); outline: none; }

.msgLog { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 12px 12px 8px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #33333b transparent; outline: none; }
.msgWin.isLoading .msgLog { opacity: 0.5; }
.msgDay { align-self: center; margin: 12px 0 4px; font-size: 10.5px; font-weight: 500; letter-spacing: 1.2px; text-transform: uppercase; color: var(--fg-mute); }
.msgDay:first-child { margin-top: 2px; }
.msgOlder { align-self: center; padding: 2px 0 6px; font-size: 11.5px; color: var(--fg-mute); }
.msgLine { display: flex; margin-top: 8px; }
.msgLine.isJoined { margin-top: 2px; }
.msgLine.isMine { justify-content: flex-end; }
.msgText { max-width: 80%; padding: 7px 12px; font-size: 14px; line-height: 1.4; color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-elev-2); border-radius: 16px 16px 16px 5px; }
.msgLine.isMine .msgText { color: #fff; background: #5e161d; border-radius: 16px 16px 5px 16px; }
.msgLine.isPending .msgText { opacity: 0.6; }
.msgText a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msgSeen { align-self: flex-end; margin: 3px 4px 0 0; font-size: 11px; color: var(--fg-mute); }
.msgEmpty { margin: auto; padding: 10px; text-align: center; }
.msgEmpty .msgAv.isBig { width: 72px; height: 72px; }
.msgEmptyName { margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--silver-1); }
.msgEmptySub { margin-top: 2px; font-size: 12.5px; color: var(--fg-mute); min-height: 18px; }
.msgTyping { flex: none; padding: 0 14px 6px; font-size: 12px; color: var(--fg-mute); }
.msgNote { flex: none; margin: 0 10px 8px; padding: 7px 10px; font-size: 12.5px; line-height: 1.4; color: #ffb4ba; background: rgba(212, 32, 47, 0.1); border: 1px solid rgba(212, 32, 47, 0.35); border-radius: 6px; }

.msgForm { display: flex; align-items: flex-end; gap: 8px; flex: none; padding: 8px 10px 10px; border-top: 1px solid var(--line-soft); }
.msgInput { flex: 1 1 auto; min-width: 0; min-height: 36px; max-height: 104px; padding: 8px 13px; font: inherit; font-size: 14px; line-height: 1.35; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 18px; resize: none; outline: none; overflow-y: hidden; scrollbar-width: thin; transition: border-color 0.15s; }
.msgInput::placeholder { color: var(--fg-mute); }
.msgInput:focus { border-color: var(--silver-2); }
.msgSend { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; padding: 0; color: #fff; background: var(--red); border: 0; border-radius: 50%; cursor: pointer; transition: background 0.15s; }
.msgSend svg { width: 18px; height: 18px; display: block; margin-left: 2px; }
.msgSend:hover { background: var(--red-bright); }
.msgSend:disabled { color: var(--fg-mute); background: var(--bg-elev-2); cursor: default; }
.msgSend:focus-visible { outline: 2px solid var(--silver-2); outline-offset: 2px; }
.msgCant { flex: none; padding: 12px 14px 14px; font-size: 13px; line-height: 1.45; color: var(--fg-dim); text-align: center; border-top: 1px solid var(--line-soft); }
.msgCant .btn { margin-top: 10px; }

/* ---------- minimised: bubbles up the corner ---------- */
.msgChips { position: fixed; z-index: 401; right: 16px; bottom: 16px; display: flex; flex-direction: column-reverse; gap: 10px; }
.msgChip { position: relative; }
.msgChipBtn { position: relative; display: block; width: 52px; height: 52px; padding: 0; background: none; border: 0; border-radius: 50%; cursor: pointer; }
.msgChipBtn .msgAv { width: 52px; height: 52px; background: var(--bg-elev); box-shadow: 0 0 0 1px var(--line), 0 8px 22px rgba(0, 0, 0, 0.6); }
.msgChipBtn:hover .msgAv { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3), 0 8px 22px rgba(0, 0, 0, 0.6); }
.msgChipBtn:focus-visible { outline: 2px solid var(--silver-2); outline-offset: 3px; }
.msgChipBtn .msgBadge { top: -3px; right: -3px; }
/* Its close button shows when the pointer is on the bubble (a finger closes from the conversation instead). */
.msgChipClose { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; color: var(--fg); background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 50%; opacity: 0; transition: opacity 0.12s; }
.msgChipClose svg { width: 12px; height: 12px; }
.msgChip:hover .msgChipClose, .msgChipClose:focus-visible { opacity: 1; }
@media (hover: none) { .msgChipClose { display: none; } }

/* ---------- a phone: the list and a conversation fill the screen ---------- */
@media (max-width: 700px) {
	/* On html only: with the body one screen tall, hiding it on both would drop the page back to its top. */
	html.msgSheetOpen { overflow: hidden; }
	/* Sized to what is visible (messages.js follows the keyboard); never vh. */
	.msgPanel, .msgWin { position: fixed; z-index: 1500; left: 0; right: 0 !important; top: var(--msgTop, 0px) !important; width: auto; max-width: none; height: var(--msgHeight, 100%); max-height: none; border: 0; border-radius: 0; box-shadow: none; }
	.msgDock { right: 0; }
	.msgRoot.hasChips .msgDock { right: 0; }
	.msgWinHead { padding: 8px 6px; border-radius: 0; }
	.msgBack { display: inline-flex; }
	.msgIconBtn { width: 38px; height: 38px; }
	.msgIconBtn svg { width: 21px; height: 21px; }
	.msgPanelHead { padding: 12px 8px 10px 16px; }
	.msgPanelTitle { font-size: 19px; }
	.msgRow { padding: 10px; }
	.msgAv { width: 48px; height: 48px; }
	.msgInput { font-size: 16px; }   /* smaller text makes iOS zoom the page on focus */
	.msgText { font-size: 15px; max-width: 84%; }
	.msgForm { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
	.msgChips { right: 12px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
	.msgChipBtn, .msgChipBtn .msgAv { width: 56px; height: 56px; }
}
