/* ==========================================================================
   Chat kit (public/js/chat-kit.js): the hall and the table chats.
   Item chips with a preview card, the composer tray (attached item, notes,
   length counter), the anti-flood countdown on the send button, and the staff
   highlight in the common hall chat.
   ========================================================================== */

/* ---------- item chip (in a message and in the composer) ---------- */
.chat-item {
  --rar: #a7adb8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 2px 0;
  padding: 2px 10px 2px 3px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--rar) 13%, rgba(12, 10, 16, 0.55));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rar) 48%, transparent);
  color: var(--rar);
  font: inherit;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0;
  text-align: left;
  vertical-align: middle;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
button.chat-item:hover,
button.chat-item:focus-visible {
  background: color-mix(in srgb, var(--rar) 22%, rgba(12, 10, 16, 0.55));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rar) 75%, transparent), 0 0 14px color-mix(in srgb, var(--rar) 22%, transparent);
  outline: none;
}
.chat-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-name::before { content: "["; opacity: 0.55; }
.chat-item-name::after { content: "]"; opacity: 0.55; }
.chat-item-art {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  background: #0c0a10;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rar) 60%, transparent);
}
.chat-item-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-item-art.is-gem {
  border-radius: 3px;
  transform: rotate(45deg) scale(0.66);
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.75) 0 10%, transparent 12%),
    conic-gradient(from 45deg, var(--rar), color-mix(in srgb, var(--rar) 50%, #000), var(--rar), color-mix(in srgb, var(--rar) 65%, #fff), var(--rar));
  box-shadow: 0 0 8px color-mix(in srgb, var(--rar) 45%, transparent);
}
.chat-item-x {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  margin: -2px -8px -2px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  font-size: 17px;
  line-height: 1;
  opacity: 0.7;
  cursor: pointer;
}
.chat-item-x:hover { opacity: 1; background: color-mix(in srgb, var(--rar) 20%, transparent); }
.rm-msg-bubble .chat-item,
.hall-log .said .chat-item { max-width: min(100%, 28ch); }

/* ---------- preview card (hover on desktop, first tap on a phone) ---------- */
.chat-item-card {
  --rar: #a7adb8;
  position: fixed;
  z-index: 10000;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 268px;
  max-width: calc(100vw - 16px);
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-solid, #16121a);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px color-mix(in srgb, var(--rar) 42%, transparent);
  pointer-events: none;
  animation: chat-card-in 0.14s ease-out;
}
@keyframes chat-card-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-item-card { animation: none; } }
.chat-item-card-art {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  background: #0c0a10;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rar) 50%, transparent), 0 0 18px color-mix(in srgb, var(--rar) 22%, transparent);
}
.chat-item-card-art .thumb { min-height: 0; }
.chat-item-card-art .thumb-title { min-height: 0; padding: 6px; font-size: 12px; }
.chat-item-card-art .thumb-face { --size: 64px; }
.chat-item-card-art .thumb-effect { width: 40px; height: 40px; }
.chat-item-card-art .thumb-bubble { padding: 5px 6px; font-size: 10px; }
.chat-item-card-info { min-width: 0; }
.chat-item-card-rar { margin: 0; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--rar); }
.chat-item-card-name { display: block; margin: 2px 0 4px; font-family: var(--display); font-size: 18px; font-weight: 600; line-height: 1.15; color: var(--ink); overflow-wrap: anywhere; }
.chat-item-card-slot { margin: 0; font-size: 12px; line-height: 1.35; color: var(--muted); }
.chat-item-card-hint { margin: 6px 0 0; font-size: 11px; color: var(--faint); }

/* ---------- composer tray + anti-flood countdown ---------- */
.chat-tray {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 14px 0;
  font-size: 12px;
  line-height: 1.3;
}
.chat-tray[hidden] { display: none; }
.chat-tray-item { display: flex; flex: 0 1 auto; min-width: 0; }
.chat-tray-item:empty { display: none; }
.chat-tray-item .chat-item { cursor: default; }
.chat-tray-note { flex: 1 1 auto; min-width: 0; color: var(--muted); }
.chat-tray-note.is-error { color: var(--danger); }
.chat-tray-note.is-wait { color: var(--gold); }
.chat-tray-count { flex: none; margin-left: auto; color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.chat-tray-count[hidden] { display: none; }
.chat-tray-count.is-over { color: var(--danger); }
.chat-composer button[type="submit"] { position: relative; }
.chat-composer button.is-cooling { cursor: progress; filter: saturate(0.4); opacity: 0.6; }
.chat-composer button.is-cooling > svg { opacity: 0; }
.chat-composer button.is-cooling::after {
  content: attr(data-wait);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------- staff and moderators in the common hall chat ----------
   Same language as the profile marks (.staff in pages.css): gold for the team (crown for the owner),
   a green shield for moderators. Calm on purpose: a tint, a thin bar on the left, a ring on the avatar, a badge. */
.hall-log .bubble.is-staff {
  --role: var(--gold);
  position: relative;
  border-radius: 4px 12px 12px 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--role) 12%, transparent), color-mix(in srgb, var(--role) 3%, transparent) 72%);
  box-shadow: inset 2px 0 0 var(--role), inset 0 0 0 1px color-mix(in srgb, var(--role) 14%, transparent);
}
.hall-log .bubble.is-mod { --role: var(--ok); }
.hall-log .bubble.is-staff:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--role) 17%, transparent), color-mix(in srgb, var(--role) 5%, transparent) 72%);
}
.hall-log .bubble.is-staff > img { box-shadow: 0 0 0 1.5px var(--role), 0 0 10px color-mix(in srgb, var(--role) 35%, transparent); }
.hall-log .bubble.is-team .who { color: var(--gold-2); }
.hall-log .bubble.is-staff .said { color: var(--ink); }
.hall-log .who { flex-wrap: wrap; row-gap: 2px; }
.hall-log .who .when { margin-left: auto; }
/* the staff pill next to the nickname is the shared .role-badge (pages.css, partials/role-badge.ejs) */
html[data-theme="light"] .hall-log .bubble.is-team .who { color: var(--cran-2); }

/* ---------- replies and @mentions in the common hall chat (public/js/hall.js) ----------
   «Ответить» appears on hover (desktop) or as a small arrow (touch; long-press works too). The quote bar
   above a message jumps to the original; a message that mentions ME gets a soft cranberry tint. */
.hall-log .bubble.chat { position: relative; }
.hall-log .bubble.chat > div { min-width: 0; } /* a long quote must not widen the grid column */
.hall-face { display: block; width: 30px; height: 30px; margin-top: 2px; border-radius: 50%; }
.hall-log .bubble > .hall-face img { display: block; width: 30px; height: 30px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line-2); }
.hall-log .bubble.is-staff > .hall-face img { box-shadow: 0 0 0 1.5px var(--role), 0 0 10px color-mix(in srgb, var(--role) 35%, transparent); }

.hall-act {
  position: absolute;
  top: 5px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-solid, #16121a);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 4px 12px rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 18px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.hall-log .bubble:hover > .hall-act,
.hall-act:focus-visible { opacity: 1; }
.hall-act:hover,
.hall-act:focus-visible { color: var(--gold); outline: none; box-shadow: inset 0 0 0 1px var(--gold), 0 4px 12px rgba(0, 0, 0, 0.25); }
@media (hover: none), (pointer: coarse) {
  .hall-act { top: 0; right: 0; width: 34px; height: 30px; padding: 0; justify-content: center; background: none; box-shadow: none; font-size: 15px; opacity: 0.6; }
  .hall-act span { display: none; }
  .hall-log .bubble.chat .who { padding-right: 26px; }
  .hall-log .bubble.chat { -webkit-touch-callout: none; }
}
.hall-act span { font-size: 11.5px; }

.hall-quote {
  display: flex;
  width: fit-content;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  margin: 3px 0 3px;
  padding: 2px 9px 2px 8px;
  border: 0;
  border-left: 2px solid color-mix(in srgb, var(--gold) 70%, transparent);
  border-radius: 2px 8px 8px 2px;
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.hall-quote:hover,
.hall-quote:focus-visible { background: color-mix(in srgb, var(--gold) 14%, transparent); outline: none; }
.hall-quote b { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2, var(--ink)); font-weight: 800; }
.hall-quote span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hall-quote.is-gone { font-style: italic; opacity: 0.75; }

.hall-mention {
  padding: 0 4px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--gold) 15%, transparent);
  color: var(--gold-2, var(--gold));
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.hall-mention:hover { background: color-mix(in srgb, var(--gold) 24%, transparent); }
.hall-mention.is-me { background: color-mix(in srgb, var(--cran) 30%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cran) 55%, transparent); }
html[data-theme="light"] .hall-mention { color: var(--cran-2, var(--cran)); }

.hall-log .bubble.is-mention {
  border-radius: 4px 12px 12px 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cran) 14%, transparent), color-mix(in srgb, var(--cran) 3%, transparent) 75%);
  box-shadow: inset 2px 0 0 var(--cran);
}
.hall-log .bubble.is-mention:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--cran) 19%, transparent), color-mix(in srgb, var(--cran) 5%, transparent) 75%); }
.hall-log .bubble.is-flash { animation: hall-flash 1.6s ease-out; }
@keyframes hall-flash {
  0%, 35% { background: color-mix(in srgb, var(--gold) 26%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent); }
  100% { box-shadow: inset 0 0 0 1px transparent; }
}
@media (prefers-reduced-motion: reduce) { .hall-log .bubble.is-flash { animation: none; outline: 1px solid var(--gold); } }

/* the quote above the composer */
.hall-replying {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 8px 12px 0;
  padding: 4px 4px 4px 10px;
  border-left: 2px solid var(--gold);
  border-radius: 2px 10px 10px 2px;
  background: color-mix(in srgb, var(--gold) 9%, transparent);
  font-size: 12.5px;
  line-height: 1.35;
}
.hall-replying[hidden] { display: none; }
.hall-replying-mark { flex: none; color: var(--gold); font-weight: 800; }
.hall-replying-what { display: flex; flex: 1; align-items: baseline; gap: 6px; min-width: 0; color: var(--muted); white-space: nowrap; }
.hall-replying-what b { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 800; }
.hall-replying-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hall-replying-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.hall-replying-x:hover { color: var(--ink); background: var(--line-soft); }

/* @ autocomplete above the input */
.hall-form { position: relative; }
.hall-suggest {
  position: absolute;
  left: 12px;
  right: 68px;
  bottom: calc(100% + 4px);
  z-index: 30;
  margin: 0;
  padding: 4px;
  list-style: none;
  border-radius: 12px;
  background: var(--surface-solid, #16121a);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), inset 0 0 0 1px var(--line-2);
}
.hall-suggest[hidden] { display: none; }
.hall-suggest li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-height: 36px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.hall-suggest li b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 13.5px; }
.hall-suggest li small { flex: none; color: var(--faint); font-size: 11px; }
.hall-suggest li.is-active,
.hall-suggest li:hover { background: color-mix(in srgb, var(--gold) 14%, transparent); }

/* unread mention marks: in the hall head and on the phone «Зал» button */
.hall-at {
  margin-top: 4px;
  padding: 1px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--grad-cran, var(--cran));
  color: #fff;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 18px;
  cursor: pointer;
}
.hall-at[hidden] { display: none; }
.hall-fab-at[hidden] { display: none !important; }
.hall-fab .hall-fab-at { background: var(--gold); color: #1b1410; }

/* ---------- hall: menu on a nickname / avatar (public/js/hall.js openMenu) ----------
   A popover next to the nick on desktop, a bottom sheet on phones (≤480px). Moderation lives here now,
   not as links under every message. */
.hall-log .who a[aria-haspopup] { cursor: pointer; }
.hall-face[aria-haspopup] { cursor: pointer; }
button.hall-sys-seal { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
button.hall-sys-seal:hover, button.hall-sys-seal:focus-visible { text-decoration: underline; outline: none; }
.hall-menu {
  position: fixed;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: min(300px, calc(100vw - 16px));
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-solid, #16121a);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--line-2);
  animation: chat-card-in 0.12s ease-out;
}
.hall-menu-head {
  margin: 0;
  padding: 6px 10px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-2, var(--gold));
  font-size: 13px;
  font-weight: 800;
}
.hall-menu-sep {
  margin: 6px 4px 2px;
  padding: 8px 6px 2px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hall-menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 38px;
  justify-content: center;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.hall-menu-item small { color: var(--faint); font-size: 11px; font-weight: 500; }
.hall-menu-item:hover,
.hall-menu-item:focus-visible { background: color-mix(in srgb, var(--gold) 14%, transparent); outline: none; }
.hall-menu-item.is-danger { color: var(--danger); }
.hall-menu-item.is-danger:hover,
.hall-menu-item.is-danger:focus-visible { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.hall-menu-mute { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 4px 6px 4px 10px; color: var(--ink); font-size: 14px; font-weight: 600; }
.hall-menu-mute > span { flex: 1; }
.hall-menu-term {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}
.hall-menu-term:hover,
.hall-menu-term:focus-visible { background: color-mix(in srgb, var(--danger) 26%, transparent); outline: none; }
.hall-menu-veil { position: fixed; inset: 0; z-index: 10000; background: var(--veil, rgba(7, 6, 10, 0.6)); animation: fade-in 0.15s ease-out; }
.hall-menu.is-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  max-width: none;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  animation: hall-sheet-in 0.18s ease-out;
}
.hall-menu.is-sheet .hall-menu-item,
.hall-menu.is-sheet .hall-menu-mute { min-height: 46px; font-size: 15px; }
.hall-menu.is-sheet .hall-menu-head { text-align: center; }
@keyframes hall-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hall-menu, .hall-menu.is-sheet, .hall-menu-veil { animation: none; } }

.hall-suggest-hint { color: var(--muted); font-size: 12.5px; cursor: default !important; background: none !important; }
