/* Chat: a VOID server like Discord's: a slim server rail, the channel list, and the conversation in the middle. Black and white, round, no gradients. */
.chat { box-sizing: border-box; display: grid; grid-template-columns: 19rem minmax(0, 1fr) 13rem; grid-template-rows: minmax(0, 1fr); gap: var(--s-4); height: 100%; } /* fills the screen: the view is .is-fill, so only the message list scrolls */
.chat-gate { grid-column: 1 / -1; display: grid; justify-items: center; gap: var(--s-4); max-width: 30rem; margin: 8vh auto 0; text-align: center; }
.chat-gate h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); }
.chat-gate p { margin: 0; color: var(--muted); }
.chat-gate .btn { text-decoration: none; }

/* Server rail and channel list */
.chat-side { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr); gap: var(--s-3); align-items: start; min-height: 0; padding-right: var(--s-3); border-right: 1px solid var(--line-strong); }
.chat-rail { display: grid; justify-items: center; gap: var(--s-2); }
.chat-rail-btn { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: none; color: var(--muted); font: inherit; font-weight: 800; cursor: pointer; transition: border-radius var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.chat-rail-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-rail-btn:hover { border-radius: 1rem; color: var(--white); }
.chat-rail-btn.is-active { border-radius: 1rem; border-color: var(--white); background: var(--white); color: var(--black); }
.chat-rail-line { width: 1.5rem; height: 1px; background: var(--line-strong); }
.chat-panel { display: grid; align-content: start; gap: var(--s-4); min-width: 0; max-height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgb(var(--fg-rgb) / 0.28) transparent; }
.chat-server { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--line); }
.chat-server strong { font-size: 1.125rem; }
.chat-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.chat-group h2 { margin: 0; padding: 0 var(--s-3) var(--s-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.chat-channel { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-md); background: none; color: var(--muted); font: inherit; text-align: left; cursor: pointer; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.chat-channel:hover { color: var(--white); background: rgb(var(--fg-rgb) / 0.06); }
.chat-channel.is-active { color: var(--white); background: rgb(var(--fg-rgb) / 0.09); }
.chat-channel span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-hash { flex: none; width: 1.25rem; text-align: center; font-weight: 700; }
.chat-channel .avatar { flex: none; width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }
.chat-note { margin: 0; padding: var(--s-2) var(--s-3); color: var(--muted); font-size: 0.875rem; }

/* Conversation */
.chat-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.chat-top { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0 var(--s-3); border-bottom: 1px solid var(--line); }
.chat-top h1 { margin: 0; font-size: 1.125rem; }
.chat-top p { flex: 1; margin: 0; min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.875rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-menu { display: none; }
.chat-menu svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-thread { display: flex; flex-direction: column; gap: 2px; min-height: 0; padding: var(--s-4) 0; overflow-y: auto; overscroll-behavior: contain; }
.chat-thread > :first-child { margin-top: auto; } /* short threads sit at the bottom, long ones scroll */
.chat-day { margin: var(--s-4) 0 var(--s-2); color: var(--muted); font-size: 0.75rem; text-align: center; letter-spacing: 0.06em; text-transform: uppercase; }
.chat-msg { display: grid; align-items: start; grid-template-columns: 2.5rem minmax(0, 1fr); gap: var(--s-3); padding: 2px var(--s-3); border-radius: var(--r-sm); }
.chat-msg { position: relative; }
.chat-msg:hover { background: rgb(var(--fg-rgb) / 0.05); }
.chat-msg.is-first { margin-top: var(--s-3); padding-top: var(--s-2); }
.chat-msg.is-mention { background: rgb(var(--fg-rgb) / 0.09); box-shadow: inset 2px 0 0 var(--white); }
.chat-msg .avatar { width: 2.5rem; height: 2.5rem; }
.chat-gutter { color: transparent; font-size: 0.6875rem; line-height: 1.5rem; text-align: right; user-select: none; }
.chat-msg:hover .chat-gutter { color: var(--muted); }
.chat-head { display: flex; align-items: baseline; gap: var(--s-2); }
.chat-head strong { color: var(--white); }
.chat-head time { color: var(--muted); font-size: 0.75rem; }
.chat-body { margin: 0; color: var(--white); overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-ping { padding: 0 0.25rem; border-radius: 6px; background: rgb(var(--fg-rgb) / 0.14); }
.chat-empty { display: grid; justify-items: center; gap: var(--s-2); margin-block: auto; padding: var(--s-6) 0; color: var(--muted); text-align: center; }
.chat-empty h2 { margin: 0; color: var(--white); font-size: 1.25rem; }

/* Names, profile card, small buttons */
.chat-who, .chat-name { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.chat-who { border-radius: 50%; line-height: 0; }
.chat-name { color: var(--white); font-weight: 700; }
.chat-name:hover { text-decoration: underline; }
.chat-small { display: inline-flex; align-items: center; padding: 0.2rem 0.85rem; border: 1px solid var(--line-strong); border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 0.8125rem; text-decoration: none; cursor: pointer; transition: color var(--dur-fast), border-color var(--dur-fast); }
.chat-small:hover { color: var(--white); border-color: var(--white); }
.chat-small.is-solid { border-color: var(--white); background: var(--white); color: var(--black); }
.chat-small.is-solid:hover { background: var(--white-2); color: var(--black); }
.chat-small[hidden] { display: none; }
.chat-card { position: fixed; z-index: 60; display: grid; gap: var(--s-2); min-width: 12rem; padding: var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg-1); box-shadow: var(--shadow-float); }
.chat-card span { color: var(--muted); font-size: 0.8125rem; }
.chat-card-actions { display: flex; gap: var(--s-2); }

/* Pictures (DMs only) */
.chat-media { display: grid; gap: 2px; width: fit-content; max-width: min(100%, 24rem); margin: var(--s-1) 0 0; }
.chat-media img { display: block; max-width: 100%; max-height: 20rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); }
.chat-media figcaption { color: var(--muted); font-size: 0.75rem; }
.chat-gone { margin: 0; color: var(--muted); font-size: 0.875rem; font-style: italic; }
.chat-shot { position: relative; justify-self: start; }
.chat-shot img { display: block; max-height: 5.5rem; max-width: 12rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); }
.chat-shot button { position: absolute; top: -0.5rem; right: -0.5rem; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--bg-0); color: var(--white); cursor: pointer; }
.chat-shot button svg { width: 0.75rem; height: 0.75rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.chat-shot[hidden] { display: none; }

/* Message box */
.chat-composer { position: relative; display: grid; gap: var(--s-2); padding-top: var(--s-2); }
.chat-box { display: flex; align-items: flex-end; gap: var(--s-1); padding: var(--s-2); border: 1px solid var(--line-strong); border-radius: 1.75rem; background: var(--bg-1); }
.chat-box[hidden] { display: none; }
.chat-box textarea { flex: 1; min-width: 0; min-height: 2.7rem; max-height: 9rem; padding: 0.55rem var(--s-3); border: 0; background: none; color: var(--white); font: inherit; resize: none; }
.chat-box textarea:focus { outline: none; }
.chat-box .gbtn { width: 2.5rem; height: 2.5rem; }
.chat-box .gbtn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-send { background: var(--white); color: var(--black); }
.chat-send:hover { background: var(--white-2); color: var(--black); }
.chat-send:disabled { opacity: 0.35; cursor: default; }
.chat-locked { margin: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); color: var(--muted); text-align: center; }

@media (max-width: 52rem) {
  .chat, .chat.no-members { grid-template-columns: minmax(0, 1fr); }
  .chat { grid-template-rows: auto minmax(0, 1fr); }
  .chat-side { display: none; max-height: 14rem; padding: 0 0 var(--s-3); border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .chat-panel { max-height: 12rem; }
  .chat.is-side-open .chat-side { display: grid; }
  .chat-menu { display: grid; }
}

/* People search, friends in the DM list */
.chat-search { width: 100%; padding: var(--s-2) var(--s-3); border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg-1); color: var(--white); font: inherit; font-size: 0.9375rem; }
.chat-search:focus { outline: none; border-color: var(--white); }
.chat-dm-body { display: grid; gap: var(--s-4); }
.chat-person { display: flex; align-items: center; gap: var(--s-1); }
.chat-person .chat-channel { flex: 1; min-width: 0; }
.chat-tag { margin-right: var(--s-2); color: var(--muted); font-size: 0.75rem; }

/* @mention suggestions above the message box */
.chat-suggest { position: absolute; right: 0; bottom: 100%; left: 0; z-index: 6; display: grid; gap: 2px; margin: 0 0 var(--s-2); padding: var(--s-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--bg-1); list-style: none; }
.chat-suggest li { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-3); border-radius: var(--r-sm); color: var(--muted); cursor: pointer; }
.chat-suggest li.is-picked, .chat-suggest li:hover { background: rgb(var(--fg-rgb) / 0.09); color: var(--white); }
.chat-suggest .avatar { width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }
.chat-suggest small { margin-left: auto; color: var(--muted); }
.chat-suggest[hidden] { display: none; }

/* Online now, presence dots, typing */
.chat.no-members { grid-template-columns: 19rem minmax(0, 1fr); }
.chat.no-members .chat-members { display: none; }
.chat-members { display: grid; align-content: start; gap: 2px; min-height: 0; padding-left: var(--s-3); overflow-y: auto; border-left: 1px solid var(--line-strong); }
.chat-members h2 { margin: 0; padding: var(--s-2) var(--s-3); color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.chat-face { position: relative; display: inline-flex; flex: none; }
.chat-face.is-on::after, .chat-dot { content: ""; position: absolute; right: -2px; bottom: -2px; width: 0.625rem; height: 0.625rem; border: 2px solid var(--bg-0); border-radius: 50%; background: var(--white); }
.chat-dot { position: static; display: inline-block; flex: none; margin-right: var(--s-2); vertical-align: middle; }
.chat-typing { height: 1.25rem; margin: 0; padding: 0 var(--s-4); color: var(--muted); font-size: 0.8125rem; line-height: 1.25rem; }
.chat-typing.is-subtle { font-size: 0.6875rem; opacity: 0.6; }
.chat-dots { display: inline-flex; gap: 2px; margin-left: 3px; }
.chat-dots i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; animation: chat-dot 1s ease-in-out infinite; }
.chat-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 40% { opacity: 0.2; translate: 0 -2px; } }
@media (min-width: 52.01rem) and (max-width: 72rem) {
  .chat, .chat.no-members { grid-template-columns: 19rem minmax(0, 1fr); }
  .chat-members { display: none; }
}

/* Message tools, reports, staff controls */
.chat-tools { position: absolute; top: -0.9rem; right: var(--s-3); z-index: 2; display: flex; gap: var(--s-1); opacity: 0; transition: opacity var(--dur-fast); }
.chat-msg:hover .chat-tools, .chat-msg:focus-within .chat-tools { opacity: 1; }
.chat-tools .chat-small { background: var(--bg-1); }
@media (hover: none) { .chat-tools { opacity: 1; } }
.chat-group.is-offline .chat-channel { opacity: 0.55; }
.chat-card { max-width: 18rem; }
.chat-card strong { display: flex; align-items: center; }
.chat-card-staff { display: flex; flex-wrap: wrap; gap: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--line); }
.chat-card-staff[hidden], .chat-card [hidden] { display: none; }
.chat-select, .chat-reason-input { padding: var(--s-1) var(--s-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg-2); color: var(--white); font: inherit; font-size: 0.8125rem; }
.chat-reason-input { resize: none; }
.chat-report { display: grid; gap: var(--s-2); margin: 0 0 var(--s-3); padding: var(--s-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); }
.chat-report .chat-card-actions { flex-wrap: wrap; }
.chat-reason { margin: 0; color: var(--muted); font-size: 0.875rem; }
.chat-form[hidden], .chat-composer[hidden] { display: none; }
.chat-thread:has(.chat-report) > :first-child { margin-top: 0; }

/* Unread */
.chat-channel.has-unread { color: var(--white); font-weight: 700; }
.chat-unread { flex: none; width: 0.5rem; height: 0.5rem; margin-left: auto; border-radius: 50%; background: var(--white); }
.chat-unread.is-ping { display: grid; place-items: center; width: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem; border-radius: 999px; color: var(--black); font-size: 0.6875rem; font-weight: 800; }
.chat-rail-btn { position: relative; }
.chat-rail-badge { position: absolute; top: -2px; right: -2px; display: grid; place-items: center; width: 0.75rem; height: 0.75rem; border: 2px solid var(--bg-0); border-radius: 50%; background: var(--white); color: var(--black); font-size: 0.625rem; font-weight: 800; }
.chat-rail-badge.has-count { width: auto; min-width: 1.125rem; height: 1.125rem; padding: 0 0.25rem; border-radius: 999px; }

/* Edited and deleted messages */
.chat-edited { color: var(--muted); font-size: 0.75rem; }
.chat-history { display: grid; gap: 2px; margin: var(--s-1) 0; padding-left: var(--s-3); border-left: 2px solid var(--line-strong); }
.chat-was { margin: 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-was span { margin-right: var(--s-2); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; }
.chat-msg.is-deleted .chat-body { color: var(--muted); text-decoration: line-through; }
.chat-deleted-tag { color: var(--muted); font-size: 0.75rem; font-style: italic; }
.chat-edit { display: grid; gap: var(--s-2); }
.chat-edit textarea { width: 100%; padding: var(--s-2) var(--s-3); border: 1px solid var(--white); border-radius: var(--r-sm); background: var(--bg-1); color: var(--white); font: inherit; resize: none; }
.chat-edit textarea:focus { outline: none; }
.chat-hint { align-self: center; color: var(--muted); font-size: 0.75rem; }

/* Image library: picker, requests, staff queue */
.chat-imgdialog { width: min(100% - 2rem, 40rem); max-height: min(36rem, 90svh); padding: var(--s-5); overflow-y: auto; border: 1px solid var(--line-strong); color: var(--white-2); }
.chat-imgdialog::backdrop { background: rgb(0 0 0 / 0.6); }
.chat-imghead { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.chat-imghead h2 { margin: 0; font-size: 1.125rem; }
.chat-imghead .gbtn svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chat-imgbody { margin-top: var(--s-4); }
.chat-imggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.chat-imgtile, .chat-imgcard { display: grid; gap: var(--s-1); margin: 0; padding: var(--s-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: none; color: inherit; font: inherit; text-align: left; }
.chat-imgtile { cursor: pointer; }
.chat-imgtile:hover, .chat-imgtile:focus-visible { border-color: var(--white); }
.chat-imgtile img, .chat-imgcard img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); }
.chat-imgtile span, .chat-imgcard figcaption { display: grid; color: var(--muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.chat-imgcard figcaption strong { color: var(--white); }
.chat-imgform { display: grid; justify-items: start; gap: var(--s-3); }
.chat-imgform .field { width: 100%; }
.chat-imgpreview { max-width: 100%; max-height: 14rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); }
.chat-imgmine { display: grid; gap: var(--s-2); }
.chat-imgrow { display: flex; align-items: center; gap: var(--s-3); }
.chat-imgrow img { width: 3rem; height: 3rem; object-fit: cover; border-radius: var(--r-sm); }
.chat-imgrow span { display: grid; flex: 1; min-width: 0; }
.chat-imgrow small { color: var(--muted); }
.chat-imgq h2 { margin: var(--s-3) 0; font-size: 1rem; }
.chat-imgcard .chat-reason-input { width: 100%; }
.chat-thread:has(.chat-imgq) > :first-child { margin-top: 0; }
