/* Recess Chat (docs/ARCHITECTURE.md §10.2, §14.7): the game page's Chat panel (in the side panel, "the rail"), the
   full-page chat room, the /chat lobby, the editors' report desk, and the dashboard's Discord bridge box. A 2003
   chat-room window (glossy title bar, window dots, LCD head count) around a ruled notebook page of messages. Builds
   on retro.css tokens. */

/* ── The chat window ────────────────────────────────────────────────────── */

.chat {
  --chat-paper: #fffef8;
  --chat-rule: #dde7fb;
  --chat-margin: rgba(232, 57, 44, 0.28);
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 3px solid var(--rr-navy);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-chunky);
  overflow: hidden;
}

.chat-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 7px 12px;
  border-bottom: 3px solid var(--rr-navy);
  background: linear-gradient(180deg, #7d3ce6 0%, #5221a6 100%);
  color: #fff;
}
.chat-head::before {
  content: "";
  position: absolute;
  inset: 0 0 52% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.06));
  pointer-events: none;
}
.chat-head-main, .chat-head-side { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-window-dots { display: inline-flex; gap: 5px; flex: none; }
.chat-window-dots span { width: 11px; height: 11px; border: 2px solid var(--rr-navy); border-radius: 50%; background: #ff6b5e; }
.chat-window-dots span:nth-child(2) { background: #ffd400; }
.chat-window-dots span:nth-child(3) { background: #36d26b; }
.chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  color: #fff;
  font: 700 15px/1.2 var(--font-pixel);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-live-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border: 2px solid var(--rr-navy);
  border-radius: 50%;
  background: #ffd400;
}
.chat[data-chat-state="live"] .chat-live-dot { background: #93ff6e; animation: chat-pulse 2.4s ease-in-out infinite; }
.chat[data-chat-state="reconnecting"] .chat-live-dot,
.chat[data-chat-state="offline"] .chat-live-dot,
.chat[data-chat-state="closed"] .chat-live-dot { background: #ff6b5e; }
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(147, 255, 110, 0.75); }
  50% { box-shadow: 0 0 0 6px rgba(147, 255, 110, 0); }
}
.chat-here { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.chat-here-label { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.chat-pop { color: #fff; font-weight: 700; font-size: 12px; white-space: nowrap; }
.chat-pop:hover { color: #ffd400; }
.chat-pop:focus-visible { outline: 3px solid #ffd400; outline-offset: 2px; border-radius: 4px; }
/* "Full room" widens the side panel in Big Screen (the page adds .rr-rail-wide); then the same link narrows it. */
.chat-pop-narrow { display: none; }
.rr-rail-wide .chat-pop-wide { display: none; }
.rr-rail-wide .chat-pop-narrow { display: inline; }

/* Header tools: the moderators' gear and Hide chat (chat.js un-hides them). */
.chat-tools { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chat-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 2px 10px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(20, 32, 107, 0.35);
  color: #fff;
  font: 700 12px/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}
.chat-tool[hidden] { display: none; }
.chat-tool:hover { border-color: #ffd400; color: #ffd400; }
.chat-tool:focus-visible { outline: 3px solid #ffd400; outline-offset: 1px; }
.chat-gear { min-width: 32px; justify-content: center; padding: 2px 7px; font-size: 15px; }
.chat-gear[aria-expanded="true"] { background: #ffd400; border-color: #ffd400; color: var(--rr-navy); }

/* Room settings (moderators): slow mode and Players only. */
.chat-modes {
  display: grid;
  gap: 8px;
  padding: 9px 12px 10px;
  border-bottom: 3px solid var(--rr-navy);
  background: #fffbe0;
  color: var(--rr-navy);
  font-size: 13px;
}
.chat-modes[hidden] { display: none; }
.chat-modes-slow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; border: 0; }
.chat-modes-slow legend { float: left; margin-right: 4px; padding: 0; font-weight: 700; }
.chat-mode-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 10px;
  border: 2px solid var(--rr-navy);
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}
.chat-mode-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chat-mode-choice:has(input:checked) { background: var(--rr-navy); color: #fff; }
.chat-mode-choice:has(input:focus-visible) { outline: 3px solid var(--rr-gold); outline-offset: 1px; }
.chat-mode-toggle { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.chat-mode-toggle input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; }
.chat-modes-hint { display: block; color: #4a4a6a; font-size: 12px; }
.chat-modes-note { margin: 0; color: #4a4a6a; font-size: 11.5px; }

/* The mode line everyone sees while slow mode or Players only is on. */
.chat-mode-line {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  padding: 5px 12px;
  border-bottom: 2px dashed #9fb0dc;
  background: #e9f1ff;
  color: var(--rr-navy);
  font-size: 12.5px;
  font-weight: 700;
}
.chat-mode-line[hidden] { display: none; }

/* Hide chat (per device): only the title bar and this note stay. */
.chat-off { padding: 20px 16px 18px; background: #f3f6ff; color: var(--rr-navy); text-align: center; }
.chat-off[hidden] { display: none; }
.chat-off img { display: block; margin: 0 auto 8px; }
.chat-off p { margin: 0 0 8px; }
.chat-off-text { color: #4a4a6a; font-size: 13px; }
.chat.chat-is-hidden > :not(.chat-head):not(.chat-off) { display: none; }
.chat.chat-is-hidden .chat-here, .chat.chat-is-hidden .chat-unread, .chat.chat-is-hidden .chat-pop { display: none; }

.chat-unread {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--rr-red);
  color: #fff;
  font: 700 11px/1 var(--font-body);
  box-shadow: 0 0 0 2px var(--rr-navy);
}
.chat-unread[hidden] { display: none; }

.chat-status {
  margin: 0;
  padding: 6px 12px;
  border-bottom: 2px dashed var(--rr-line);
  background: #fff6c2;
  color: var(--rr-navy);
  font-size: 12.5px;
  font-weight: 700;
}
.chat[data-chat-state="reconnecting"] .chat-status,
.chat[data-chat-state="offline"] .chat-status,
.chat[data-chat-state="closed"] .chat-status { background: #ffe3df; }

.chat-pins { padding: 6px 12px 8px; border-bottom: 2px solid #ffd400; background: #fffbe0; }
.chat-pins-label { margin: 0 0 4px; color: var(--rr-navy); font: 700 11px/1 var(--font-pixel); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-pin-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.chat-pin-btn {
  display: block;
  width: 100%;
  padding: 3px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--rr-ink);
  font: 12.5px/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-pin-btn:hover { background: #fff2a8; }

/* ── Messages ───────────────────────────────────────────────────────────── */

.chat-main { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; }
.chat-body { position: relative; min-width: 0; }
.chat-scroll {
  position: relative;
  height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(90deg, transparent 52px, var(--chat-margin) 52px, var(--chat-margin) 54px, transparent 54px),
    repeating-linear-gradient(180deg, var(--chat-paper) 0 27px, var(--chat-rule) 27px 28px);
  scroll-behavior: smooth;
}
.chat-scroll:focus-visible { outline: 3px solid #ffd400; outline-offset: -3px; }
.chat-compact .chat-scroll { height: 320px; }
.chat-full .chat-scroll { height: min(62vh, 640px); }

/* ── The rail: the Chat tab of the game page's side panel (§14.7) ──
   The section fills its panel (the page gives [data-rr-rail-panel="chat"] a definite height) and the messages scroll
   inside it: a full-height scroll that never makes the cabinet taller. */
.chat-rail {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.chat-rail .chat-head { flex-wrap: wrap; gap: 4px 8px; min-height: 0; padding: 6px 10px; border-bottom-width: 2px; }
.chat-rail .chat-head-main { gap: 8px; }
.chat-rail .chat-window-dots { display: none; }
.chat-rail .chat-title { font-size: 13px; }
.chat-rail .chat-here { font-size: 12px; }
.chat-rail .chat-tools { margin-left: auto; }
.chat-rail .chat-main { grid-template-rows: minmax(0, 1fr); }
.chat-rail .chat-body { min-height: 0; }
.chat-rail .chat-scroll {
  height: 100%;
  min-height: 120px;
  background: repeating-linear-gradient(180deg, var(--chat-paper) 0 27px, var(--chat-rule) 27px 28px);
}
.chat-rail .chat-msg { grid-template-columns: 28px minmax(0, 1fr); gap: 0 9px; padding-right: 10px; }
.chat-rail .chat-avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 7px; }
.chat-rail .chat-hidden-note { padding-left: 37px; }
.chat-rail .chat-off { flex: 1; }
.chat-rail .chat-hint-keys { display: none; }
.chat-rail .chat-composer { gap: 6px; padding: 6px 8px 8px; }
.chat-rail .chat-kind { min-height: 28px; padding: 2px 9px; font-size: 12px; }
.chat-rail .chat-modes { padding: 8px 10px; }
/* A Robot Recess line is one centered pill in every layout: the narrower two-column message grids (the rail, phones)
   must not squeeze it into the avatar column. */
.chat .chat-msg.chat-msg-system { grid-template-columns: minmax(0, 1fr); padding-right: 12px; }

.chat-more { margin: 8px 0 0; text-align: center; }
.chat-more:empty, .chat-more:has(> [hidden]) { display: none; }
.chat-empty { padding: 34px 16px; color: var(--rr-muted); text-align: center; }
.chat-empty img { display: block; margin: 0 auto 8px; }
.chat-empty p { margin: 0; }

.chat-log { margin: 0; padding: 6px 0 12px; list-style: none; }
.chat-msg {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0 12px;
  padding: 7px 12px 6px 10px;
}
.chat-msg:hover, .chat-msg:focus-within { background: rgba(31, 111, 235, 0.07); }
.chat-msg.is-cont { padding-top: 0; }
.chat-msg.is-cont > .chat-avatar { visibility: hidden; height: 0; }
.chat-msg.is-cont .chat-meta { display: none; }

.chat-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--rr-navy);
  border-radius: 9px;
  background: hsl(var(--hue, 220) 90% 84%);
  color: var(--rr-navy);
  font: 8.5px/1 var(--font-arcade);
  letter-spacing: -0.02em;
  box-shadow: inset 0 -3px 0 rgba(20, 32, 107, 0.16);
  overflow: hidden;
}
.chat-avatar-sm { width: 26px; height: 26px; border-radius: 7px; font-size: 7px; }
.chat-msg-main { min-width: 0; }
.chat-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 0 1px; font-size: 12.5px; }
.chat-name { color: hsl(var(--hue, 220) 80% 26%); font-weight: 700; text-decoration: none; }
a.chat-name:hover { text-decoration: underline; }
.chat-time { color: var(--rr-muted); font-size: 11px; }
.chat-badge {
  padding: 2px 6px;
  border: 1.5px solid var(--rr-navy);
  border-radius: 999px;
  background: #fff;
  color: var(--rr-navy);
  font: 700 10px/1.1 var(--font-body);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.chat-badge-creator { background: #ffd400; }
.chat-badge-collaborator { background: #c9f3ee; }
.chat-badge-editor { background: var(--rr-red); color: #fff; }
.chat-badge-premium { background: #ead9ff; }
.chat-kind-tag, .chat-pin-tag, .chat-hidden-tag {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.chat-kind-tag-bug { background: #ffe0dc; color: #8c1d15; }
.chat-kind-tag-idea { background: #fff1a8; color: #6a4b00; }
.chat-kind-tag-shoutout { background: #ffe0f1; color: #8a1f5e; }
.chat-pin-tag { background: #fff1a8; color: #6a4b00; }
.chat-hidden-tag { background: #ececec; color: #4c4c4c; }

.chat-text { margin: 0; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-link { font-weight: 700; }

.chat-msg-bug, .chat-msg-idea, .chat-msg-shoutout { margin: 4px 8px; border: 2px solid; border-radius: 12px; padding-left: 8px; }
.chat-msg-bug { border-color: #f3a39b; background: #fff4f2; }
.chat-msg-idea { border-color: #f2d35a; background: #fffbe6; }
.chat-msg-shoutout { border-color: #f4a6d2; background: #fff3fa; }
.chat-msg-bug:hover, .chat-msg-idea:hover, .chat-msg-shoutout:hover { background: #fff; }
.chat-msg.is-resolved { border-color: #8fd6a5; }

.chat-msg-system { grid-template-columns: minmax(0, 1fr); padding: 8px 12px; text-align: center; }
.chat-msg-system > .chat-avatar, .chat-msg-system .chat-meta { display: none; }
.chat-msg-system .chat-text {
  display: inline-block;
  padding: 4px 14px;
  border: 2px solid var(--rr-navy);
  border-radius: 999px;
  background: var(--rr-navy);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}
.chat-msg-system .chat-text .chat-link { color: #ffd400; }

.chat-msg.is-mine > .chat-avatar { box-shadow: inset 0 -3px 0 rgba(20, 32, 107, 0.16), 0 0 0 2px #ffd400; }
.chat-msg.is-mention { background: #fff6c2; box-shadow: inset 4px 0 0 var(--rr-gold); }
.chat-msg.is-pending { opacity: 0.68; }
.chat-msg.is-failed { opacity: 1; background: #fff1ef; }
.chat-pending-state { color: var(--rr-muted); font-size: 11px; font-style: italic; }
.chat-msg.is-failed .chat-pending-state { color: var(--rr-danger); font-style: normal; font-weight: 700; }
.chat-msg.is-hidden { padding-top: 4px; padding-bottom: 4px; }
.chat-hidden-note { grid-column: 1 / -1; margin: 0; padding-left: 46px; color: var(--rr-muted); font-size: 12.5px; font-style: italic; }
.chat-msg.is-hidden-mod .chat-text { color: var(--rr-muted); text-decoration: line-through; }
.chat-msg.is-flash { animation: chat-flash 1.6s ease-out; }
@keyframes chat-flash {
  0%, 30% { background: #ffe867; }
  100% { background: transparent; }
}

.chat-reply-ref {
  display: block;
  max-width: 100%;
  margin: 1px 0 3px;
  padding: 1px 8px;
  border: 0;
  border-left: 3px solid #9fb0dc;
  background: none;
  color: var(--rr-muted);
  font: 12px/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-reply-ref:disabled { cursor: default; }
.chat-reply-ref:not(:disabled):hover { color: var(--rr-navy); }

.chat-context { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 5px 0 0; color: var(--rr-muted); font-size: 12px; }
.chat-context-label { font-weight: 700; }
.chat-shot { display: block; flex-basis: 100%; }
.chat-shot img { display: block; width: auto; max-width: min(220px, 100%); height: auto; border: 2px solid var(--rr-navy); border-radius: 8px; }
.chat-resolved {
  display: inline-block;
  margin: 5px 0 0;
  padding: 2px 10px;
  border: 2px solid var(--rr-green);
  border-radius: 999px;
  background: #e3f7e9;
  color: var(--rr-ok);
  font-size: 12px;
  font-weight: 700;
}

.chat-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chat-react {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 1px 9px;
  border: 2px solid #b9c7ee;
  border-radius: 999px;
  background: #fff;
  color: var(--rr-navy);
  font: 13px/1 var(--font-body);
  cursor: pointer;
}
.chat-react:hover:not(:disabled) { border-color: var(--rr-navy); }
.chat-react.is-on { border-color: var(--rr-navy); background: #e3ebff; }
.chat-react:disabled { cursor: default; }
.chat-react-n { font-weight: 700; font-size: 12px; }

/* Message actions: a floating toolbar on hover/focus; always visible (inline) on touch screens. */
.chat-actions {
  position: absolute;
  top: -10px;
  right: 10px;
  z-index: 2;
  display: flex;
  gap: 2px;
  padding: 2px 4px;
  border: 2px solid var(--rr-navy);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(20, 32, 107, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.chat-msg:hover .chat-actions, .chat-msg:focus-within .chat-actions, .chat-actions.chat-actions-on { opacity: 1; pointer-events: auto; }
.chat-actions.chat-actions-on { position: static; margin-top: 4px; width: max-content; }
.chat-log > li:first-child .chat-actions { top: 2px; }
.chat-act {
  min-height: 28px;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--rr-navy);
  font: 700 12px/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}
.chat-act:hover, .chat-act[aria-expanded="true"] { background: #fff6c2; }
.chat-act:focus-visible, .chat-react:focus-visible, .chat-pin-btn:focus-visible, .chat-reply-ref:focus-visible,
.chat-tray-emoji:focus-visible, .chat-link-btn:focus-visible, .chat-jump:focus-visible {
  outline: 3px solid #ffd400;
  outline-offset: 1px;
  box-shadow: 0 0 0 5px var(--rr-navy);
}

.chat-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 2px solid var(--rr-navy);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(20, 32, 107, 0.2);
}
.chat-tray-title { flex-basis: 100%; margin: 0; color: var(--rr-navy); font-weight: 700; font-size: 13px; }
.chat-tray-reason { display: flex; align-items: center; gap: 6px; flex-basis: 100%; font-size: 13px; cursor: pointer; }
.chat-tray-buttons { display: flex; gap: 6px; margin: 4px 0 0; }
.chat-tray-label { margin-left: 4px; color: var(--rr-muted); font-size: 12px; font-weight: 700; }
.chat-tray-emoji {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #b9c7ee;
  border-radius: 12px;
  background: #fff;
  font-size: 21px;
  cursor: pointer;
  transition: transform 0.1s var(--ease-out), border-color 0.1s;
}
.chat-tray-emoji:hover { border-color: var(--rr-navy); transform: translateY(-2px) scale(1.08); }

.chat-jump {
  position: absolute;
  bottom: 12px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 6px 14px;
  border: 2px solid var(--rr-navy);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe867 0%, #ffc21a 55%, #ffad00 100%);
  color: var(--rr-navy);
  font: 700 12.5px/1.1 var(--font-body);
  box-shadow: 0 3px 0 var(--rr-navy);
  cursor: pointer;
}

.chat-typing {
  min-height: 22px;
  margin: 0;
  padding: 3px 12px 0;
  border-top: 2px solid var(--rr-line);
  background: #f3f6ff;
  color: var(--rr-muted);
  font-size: 12px;
  font-style: italic;
}

/* ── Composer ───────────────────────────────────────────────────────────── */

.chat-composer {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 6px 10px 10px;
  background: linear-gradient(180deg, #f3f6ff 0%, #dfe8ff 100%);
}
.chat-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.chat-kind {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 3px 11px;
  border: 2px solid var(--rr-navy);
  border-radius: 999px;
  background: #fff;
  color: var(--rr-navy);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.chat-kind input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chat-kind:hover { background: #fff6c2; }
.chat-kind:has(input:focus-visible) { outline: 3px solid #ffd400; outline-offset: 1px; }
.chat-kind:has(input:checked) { background: var(--rr-navy); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.chat-kind-bug:has(input:checked) { background: #b3261e; }
.chat-kind-idea:has(input:checked) { background: #ffd400; color: var(--rr-navy); }
.chat-kind-shoutout:has(input:checked) { background: #b42c7d; }
.chat-kind:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.chat-kind-icon { font-size: 14px; }

.chat-bug-extras { display: grid; gap: 4px; padding: 7px 10px; border: 2px dashed #f3a39b; border-radius: 10px; background: #fff4f2; font-size: 13px; }
.chat-attach-summary { color: var(--rr-muted); font-weight: 700; }
.chat-replying {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border: 2px dashed #9fb0dc;
  border-radius: 10px;
  background: #fff;
  font-size: 12.5px;
}
.chat-replying-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-replying-snippet { color: var(--rr-muted); }
.chat-link-btn { padding: 0; border: 0; background: none; color: var(--rr-link); font: 700 12.5px var(--font-body); text-decoration: underline; cursor: pointer; }

.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat .chat-input { flex: 1; min-height: 42px; max-height: 140px; resize: none; line-height: 1.4; }
.chat-send { flex: none; min-height: 42px; }
.chat-hint { margin: 0; color: var(--rr-muted); font-size: 11.5px; }
.chat-count.is-near { color: var(--rr-danger); font-weight: 700; }
.chat-error { margin: 0; color: var(--rr-danger); font-size: 12.5px; font-weight: 700; }
.chat-error.chat-error-info { color: var(--rr-ok); }

.chat-login { padding: 14px 12px; border-top: 2px solid var(--rr-line); background: linear-gradient(180deg, #f3f6ff, #dfe8ff); text-align: center; }
.chat-login-text { margin: 0 0 8px; font-size: 13.5px; }
.chat-login-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; }
.chat-noscript { margin: 0; padding: 10px 12px; background: #fff6c2; font-weight: 700; }

/* Who's here (full page) */
.chat-people { min-width: 0; padding: 10px 12px; border-left: 3px solid var(--rr-navy); background: #f3f6ff; overflow-y: auto; }
.chat-people-title { margin: 0 0 8px; color: var(--rr-navy); font: 700 12px/1.2 var(--font-pixel); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-people-list { display: grid; gap: 4px; margin: 0 0 8px; padding: 0; list-style: none; }
.chat-person { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.chat-person-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

/* ── Full-page room ─────────────────────────────────────────────────────── */

.chat-page { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.chat-page > * { min-width: 0; }
.chat-page-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.chat-full .chat-main { grid-template-columns: minmax(0, 1fr) 200px; }
.chat-full .chat-people { height: min(62vh, 640px); }
.chat-page-note { margin: 0; padding: 0 4px; color: var(--rr-navy); }

.chat-rooms {
  position: sticky;
  top: 12px;
  padding: 12px 10px;
  border: 3px solid var(--rr-navy);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-chunky);
}
.chat-rooms-title, .chat-rooms-sub {
  margin: 2px 6px 8px;
  color: var(--rr-navy);
  font: 700 13px/1.2 var(--font-pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chat-rooms-sub { margin-top: 14px; font-size: 11px; color: var(--rr-muted); }
.chat-room-list { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.chat-room-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--rr-navy);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}
.chat-room-link:hover { background: #fff6c2; color: var(--rr-navy); }
.chat-room-link.is-active { background: var(--rr-navy); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3); }
.chat-room-icon { flex: none; font-size: 18px; }
.chat-room-name { display: grid; min-width: 0; }
.chat-room-name, .chat-room-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-room-sub { color: var(--rr-muted); font-size: 11px; font-weight: 400; }
.chat-room-link.is-active .chat-room-sub { color: #c9d4ff; }
.chat-rooms-all { margin: 12px 6px 0; font-size: 12.5px; font-weight: 700; }

.chat-room-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 18px;
  border: 3px solid var(--rr-navy);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #ffffff 0%, #eef3ff 100%);
  box-shadow: var(--shadow-chunky);
}
.chat-room-kicker { margin: 0 0 4px; color: var(--rr-purple); font-size: 11px; text-transform: uppercase; }
.chat-room-title { margin: 0 0 2px; font-size: 24px; overflow-wrap: anywhere; }
.chat-room-blurb { margin: 0; color: var(--rr-muted); }
.chat-room-actions { margin: 0; }

/* ── Lobby ──────────────────────────────────────────────────────────────── */

.chat-lobby-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 3px solid var(--rr-navy);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #7433dc 0%, #b42c7d 100%);
  color: #fff;
  box-shadow: var(--shadow-chunky);
  overflow: hidden;
}
.chat-lobby-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 92% 20%, rgba(255, 255, 255, 0.22) 0 60px, transparent 61px),
    radial-gradient(circle at 80% 90%, rgba(255, 212, 0, 0.25) 0 34px, transparent 35px);
  pointer-events: none;
}
.chat-lobby-art { position: relative; flex: none; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.25)); }
.chat-lobby-kicker { margin: 0 0 6px; color: #ffd400; font-size: 11px; text-transform: uppercase; }
.chat-lobby-title { margin: 0 0 6px; color: #fff; font: 700 24px/1.2 var(--font-pixel); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.chat-lobby-lead { margin: 0; max-width: 60ch; font-size: 14.5px; }
.chat-lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.chat-lobby-sub { margin: 4px 0 8px; color: var(--rr-navy); font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }

.chat-cards { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chat-card-link {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--rr-navy);
  border-radius: 12px;
  background: #fff;
  color: var(--rr-ink);
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(20, 32, 107, 0.2);
  transition: transform 0.1s var(--ease-out), background 0.1s;
}
.chat-card-link:hover { transform: translateY(-1px); background: #fff6c2; color: var(--rr-ink); }
.chat-card-icon { font-size: 28px; text-align: center; }
.chat-card-text { display: grid; gap: 2px; min-width: 0; }
.chat-card-name { color: var(--rr-navy); font-weight: 700; font-size: 15px; }
.chat-card-blurb { color: var(--rr-muted); font-size: 12.5px; }
.chat-card-here { display: inline-flex; align-items: center; gap: 4px; color: var(--rr-navy); font-weight: 700; font-size: 12px; white-space: nowrap; }
.chat-card-live { justify-self: start; background: var(--rr-lime); color: var(--rr-navy); }

.chat-game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 0 0 14px; padding: 0; list-style: none; }
.chat-game-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 2px solid var(--rr-navy);
  border-radius: 12px;
  background: #fff;
  color: var(--rr-ink);
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(20, 32, 107, 0.2);
}
.chat-game-card:hover { background: #fff6c2; color: var(--rr-ink); }
.chat-game-card img { flex: none; width: 72px; height: 54px; border: 2px solid var(--rr-navy); border-radius: 8px; object-fit: cover; background: #e8eefc; }
.chat-game-card-text { display: grid; gap: 2px; min-width: 0; }
.chat-game-card-title { color: var(--rr-navy); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-game-card-sub { color: var(--rr-muted); font-size: 12px; }
.chat-rules { margin: 0; padding-left: 1.2em; }
.chat-rules li + li { margin-top: 4px; }

/* ── Dashboard: Discord bridge ──────────────────────────────────────────── */

.chat-bridge { display: grid; gap: 10px; }
.chat-bridge-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.chat-bridge-intro, .chat-bridge-upsell { margin: 0; }
.chat-bridge-facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; }
.chat-bridge-facts dt { color: var(--rr-muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.chat-bridge-facts dd { margin: 0; }
.chat-bridge-mode { display: grid; gap: 6px; }
.chat-bridge-remove { margin: 0; }
.chat-bridge-on { background: #e3f7e9; color: var(--rr-ok); border-color: var(--rr-green); }
.chat-bridge-off { background: #ffe3df; color: var(--rr-danger); border-color: var(--rr-danger); }
.chat-bridge-paused { background: #fff1d6; color: #7a4a00; border-color: var(--rr-orange); }

/* ── Editors: reported messages ─────────────────────────────────────────── */

.chat-admin-body { max-width: 46ch; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-admin-actions { white-space: nowrap; }
.chat-admin-actions form { display: inline-block; margin: 0 4px 4px 0; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .chat-full .chat-main { grid-template-columns: minmax(0, 1fr); }
  .chat-full .chat-people { display: none; }
}

@media (max-width: 760px) {
  .chat-page { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .chat-rooms { position: static; padding: 8px; }
  .chat-rooms-title, .chat-rooms-sub, .chat-rooms-all { display: none; }
  .chat-room-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .chat-room-list + .chat-room-list { margin-top: 6px; }
  .chat-room-list > li { flex: none; }
  .chat-room-link { padding: 6px 10px; border: 2px solid var(--rr-navy); border-radius: 999px; }
  .chat-room-sub { display: none; }
  .chat-room-head { padding: 12px 14px; }
  .chat-room-title { font-size: 20px; }
  .chat-full .chat-scroll { height: 58vh; }
  .chat-window-dots { display: none; }
  .chat-lobby-hero { flex-direction: column; align-items: flex-start; padding: 16px; }
  .chat-lobby-art { width: 64px; }
  .chat-lobby-title { font-size: 19px; }
}

@media (max-width: 560px) {
  .chat-head { padding: 6px 10px; }
  .chat-title { font-size: 13px; }
  .chat-pop { display: none; }
  .chat-tool { min-height: 34px; }
  .chat-msg { grid-template-columns: 28px minmax(0, 1fr); gap: 0 9px; padding-right: 10px; }
  .chat-avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 7px; }
  .chat-scroll { background: repeating-linear-gradient(180deg, var(--chat-paper) 0 27px, var(--chat-rule) 27px 28px); }
  .chat-hidden-note { padding-left: 37px; }
  .chat-hint-keys { display: none; }
  .chat .chat-input { font-size: 16px; } /* no zoom-on-focus on iOS */
  .chat-card-link { grid-template-columns: 34px minmax(0, 1fr); }
  .chat-card-here { grid-column: 2; }
}

.chat-hint-touch { display: none; }

/* Touch screens: tap a message to show its actions (no hover to reveal the floating toolbar). */
@media (hover: none) {
  .chat-actions {
    position: static;
    display: none;
    flex-wrap: wrap;
    width: max-content;
    max-width: 100%;
    margin-top: 4px;
    padding: 0;
    border-width: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
  }
  .chat-msg.is-active .chat-actions, .chat-msg:focus-within .chat-actions, .chat-actions.chat-actions-on { display: flex; }
  .chat-msg.is-active { background: rgba(31, 111, 235, 0.08); }
  .chat-act { min-height: 34px; padding: 4px 10px; border: 2px solid #c6d3f0; background: #fff; }
  .chat-hint-touch { display: inline; }
  .chat-tool, .chat-mode-choice { min-height: 40px; }
  .chat-gear { min-width: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-scroll { scroll-behavior: auto; }
  .chat[data-chat-state="live"] .chat-live-dot, .chat-msg.is-flash { animation: none; }
  .chat-msg.is-flash { background: #fff6c2; }
  .chat-card-link, .chat-tray-emoji, .chat-actions { transition: none; }
  .chat-card-link:hover, .chat-tray-emoji:hover { transform: none; }
}

@media (forced-colors: active) {
  .chat-kind:has(input:checked), .chat-mode-choice:has(input:checked) { outline: 3px solid Highlight; }
  .chat-react.is-on { outline: 2px solid Highlight; }
  .chat-unread, .chat-live-dot { forced-color-adjust: none; }
}
