:is(#chat, .chat-account) [hidden] { display: none !important; }
#chat, #chat .home-heading { min-width: 0; }
#chat .home-heading { position: relative; flex-wrap: wrap; }
#chat .home-heading h2 { margin-right: auto; overflow-wrap: anywhere; }
.chat-heading-actions { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-inline-start: auto; }
.chat-panel {
  box-sizing: border-box;
  min-width: 0;
  height: calc(var(--chat-rows, 5) * 55px + 1px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.chat-feed { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.chat-placeholder, .chat-status { color: var(--quiet); margin: 0; font-size: 13px; }
.chat-placeholder { padding: 15px; }
.chat-controls {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px; align-items: center; padding: 6px 10px; border-top: 1px solid var(--line);
}
.chat-controls > :not(.chat-sound) { grid-column: 1; }
.chat-controls > .chat-sound { grid-column: 2; grid-row: 1; align-self: center; }
.chat-controls > .chat-status { grid-row: 1; align-self: center; }
.chat-controls > .chat-compose { grid-row: 2; }
.chat-controls:has(.chat-compose:not([hidden])) > .chat-sound { grid-row: 2; }
.chat-controls > .chat-link { font-size: 13px; }
.chat-status:not(:empty) { margin: 0; line-height: 1.5; }
#chat .chat-status a { display:inline; padding:0; margin:0; border:0; background:none; font:inherit; font-weight:600; line-height:inherit; vertical-align:baseline; text-decoration:none; }
.chat-rules { font-size: 14px; font-weight: 700; color: var(--brand); }
.chat-rules summary { cursor: pointer; }
.chat-rules p {
  position: absolute; z-index: 3; top: calc(100% + 6px); right: 0; margin: 0;
  box-sizing: border-box; width: min(320px, 100%); max-height: 190px; overflow: auto;
  font-size: 13px; font-weight: 400;
  padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--raised); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-compose { display: flex; gap: 7px; }
.chat-draft { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 100px; overflow: auto; }
.chat-draft:empty::before { content: attr(data-placeholder); color: var(--quiet); pointer-events: none; }
.chat-draft .chat-emote { vertical-align: text-bottom; }
.chat-draft, .chat-account-form :is(input,textarea) {
  box-sizing: border-box; border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; background: var(--paper); color: var(--ink); font: inherit;
}
.chat-button {
  border: 1px solid var(--line); border-radius: 7px; color: var(--ink);
  background: var(--raised); padding: 8px 12px; cursor: pointer; font: inherit; font-weight: 650;
}
.chat-button:hover { border-color: var(--brand); }
.chat-button:disabled { opacity: .65; cursor: wait; }
.site .chat-link { color: var(--brand); }
button.chat-link { font: inherit; border: 0; padding: 0; background: none; cursor: pointer; }
.chat-account-main { max-width: 510px; padding: 32px 16px; margin: auto; }
.chat-account-card { margin-top: 16px; padding: clamp(16px, 5vw, 26px); border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.chat-account-card p { margin: 0 0 10px; overflow-wrap: anywhere; }
.chat-account-form { display: grid; gap: 13px; }
.chat-account-form label { display: grid; gap: 5px; font-weight: 600; }
.chat-account-form small { color: var(--quiet); }
.chat-account-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; }
.chat-error { color: var(--brand); }
.chat-visually-hidden { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

.chat-message {
  --message-avatar-size: 32px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 1px 5px;
  padding: 5px 6px;
  border-radius: 7px;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.chat-avatar {
  display: inline-grid;
  place-items: center;
  inline-size: 24px;
  block-size: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--brand);
  object-fit: cover;
  font-size: 12px;
  font-weight: 700;
}
.chat-account-form .chat-avatar { inline-size: 48px; block-size: 48px; }
.chat-account-form .chat-avatar-remove { display: flex; align-items: center; }
.chat-message-content { min-width: 0; flex: 1; }
.chat-message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 7px; font-size: 12px; line-height: 15px; }
.chat-feed .chat-message:hover, .chat-feed .chat-message:focus-within {
  background: color-mix(in srgb, var(--raised) 68%, var(--surface));
}
.chat-message time { margin-inline-start: auto; color: var(--quiet); font-size: 11px; white-space: nowrap; }
.chat-message-author { min-width: 0; text-align: left; }
button.chat-message-author {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
button.chat-message-author:hover { color: var(--brand); text-decoration: underline; }
.chat-mention {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-radius: 4px;
  padding-inline: 3px;
  font-weight: 650;
}
.chat-mention-self { background: color-mix(in srgb, var(--brand) 24%, transparent); }
.chat-mod-badge { width: 14px; height: 14px; align-self: center; flex: none; }
.chat-message p { margin: 0; line-height: 18px; white-space: pre-wrap; }
.chat-emote { display: inline-block; width: 16px; height: 16px; object-fit: contain; vertical-align: top; }
.chat-message-tools {
  cursor: pointer;
  padding: 0 5px;
  line-height: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--raised);
  color: var(--ink);
}
.chat-emote-picker > summary {
  display: grid;
  height: 100%;
  box-sizing: border-box;
  place-items: center;
  list-style: none;
}
.chat-emote-picker > summary::-webkit-details-marker { display: none; }
.chat-emote-options {
  position: absolute;
  bottom: 100%;
  right: 8px;
  z-index: 2;
  display: grid;
  gap: 6px;
  box-sizing: border-box;
  width: min(540px, calc(100% - 16px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.chat-emote-faces button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.chat-moderation {
  width: min(340px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  box-sizing: border-box;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.chat-moderation::backdrop { background: #0008; }
.chat-moderation h3 { margin: 0 0 10px; overflow-wrap: anywhere; }
.chat-moderation-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
@media (max-width: 440px) {
  .chat-compose .chat-button { padding-inline: 7px; font-size: 13px; }
}

.chat-avatar-editor {
  border-block: 1px solid var(--line);
}
.chat-avatar-editor > summary {
  padding-block: 8px;
  cursor: pointer;
  font-weight: 650;
}
.chat-avatar-editor[open] { padding-bottom: 10px; }
.chat-avatar-editor .chat-avatar { overflow: hidden; }
.chat-avatar-editor .chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar-file { display: grid; min-width: 0; gap: 8px; }
.chat-avatar-file input { max-width: 100%; font-size: 13px; }
.chat-avatar-file-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.chat-avatar-file-actions button { font-size: 14px; }
@media (pointer: coarse) {
  .chat-avatar-file-actions button { min-height: 44px; }
}
.chat-avatar-sample {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--paper);
}
.chat-avatar-sample .chat-message { margin-top: 4px; padding-inline: 0; }
.chat-message > .chat-avatar {
  inline-size: var(--message-avatar-size);
  block-size: var(--message-avatar-size);
  flex-basis: var(--message-avatar-size);
}
.chat-avatar-editor [role="status"]:not(:empty) { display: block; margin-top: 7px; }
.chat-avatar-editor .chat-avatar-remove { margin-top: 8px; font-size: 13px; }

.chat-profile { max-width: 480px; }
.chat-profile .chat-account-card {
  padding: clamp(15px, 4vw, 26px);
}
.chat-profile .chat-account-form { gap: 10px; }
.chat-profile .chat-account-form > p { margin: 0; }
.chat-account-heading {
  margin-bottom: 20px;
}
.chat-account-heading > h1 { margin: 0; font-size: 26px; }
.chat-profile-cover {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.chat-profile .chat-profile-portrait {
  inline-size: 44px;
  block-size: 44px;
  flex: none;
  box-sizing: border-box;
  overflow: hidden;
  border: 0;
  font-size: 20px;
}
.chat-profile-portrait img { width: 100%; height: 100%; object-fit: cover; }
.chat-profile-identity { min-width: 0; overflow-wrap: anywhere; }
.chat-profile-identity h1 { margin: 0; font-size: 20px; }
.chat-profile-identity small { color: var(--quiet); }
.chat-account-card .chat-profile-saved {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, #329467 45%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, #329467 13%, var(--surface));
  color: var(--ink);
  font-weight: 650;
}
.chat-profile-saved span {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: none;
  border-radius: 50%;
  background: #216044;
  color: #fff;
}
.chat-profile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.chat-profile-actions .chat-link { padding: 6px 0; }
:is(.chat-account-form, .chat-profile-actions) > .chat-button {
  justify-self: start;
  background: var(--action);
  color: #fff;
  border-color: transparent;
  padding-inline: 18px;
}
:is(.chat-account-form, .chat-profile-actions) > .chat-button:hover { border-color: var(--ink); }
@media (max-width: 440px) {
  .chat-account-form > .chat-button { justify-self: stretch; }
}

.chat-emote-options .chat-emote { width: 24px; height: 24px; }

.chat-emote-packs { display: flex; flex-wrap: wrap; gap: 3px; }
.chat-emote-packs button {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px;
  cursor: pointer; color: var(--ink); font: inherit; font-size: 12px;
  background: transparent; border: 1px solid transparent; border-radius: 5px;
}
.chat-emote-packs button[aria-pressed="true"], .chat-emote-packs button:hover {
  border-color: var(--brand); background: var(--raised);
}
.chat-emote-packs button .chat-emote { width: 18px; height: 18px; }
.chat-emote-faces {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 3px; max-height: 160px; overflow: auto;
}
.chat-emote-faces button { width: 100%; height: 34px; }
.chat-emote-faces button:hover { border-color: var(--brand); }
.chat-emote-faces button .chat-emote { width: 32px; height: 32px; }

.chat-message-actions { display: flex; gap: 3px; flex: none; }
.chat-message-actions button { min-width: 23px; min-height: 24px; }

.chat-announcement {
  display: flex; gap: 8px; align-items: baseline; padding: 6px 10px;
  border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; overflow-wrap: anywhere;
  min-height: 0; max-height: 35%; overflow: auto;
  background: color-mix(in srgb, var(--brand) 10%, var(--surface)); font-size: 13px;
}
.chat-announcement > span:first-child, .chat-announcement a { color: var(--brand); }
.chat-announcement a { font-weight: 650; }
.chat-ban {
  display: grid; gap: 3px; padding: 7px 9px; border-radius: 6px;
  background: var(--raised); overflow-wrap: anywhere; font-size: 13px;
}
.chat-ban small { color: var(--quiet); font-variant-numeric: tabular-nums; }
.chat-moderation [data-chat-action-copy] {
  margin: 0 0 10px; max-height: 120px; overflow: auto; overflow-wrap: anywhere;
}
.chat-moderation label { display: grid; gap: 4px; margin-bottom: 10px; }
.chat-moderation :is(input,select) {
  box-sizing: border-box; width: 100%; padding: 7px;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 5px;
}
.chat-moderation-actions { justify-content: flex-end; margin-bottom: 0; }
.chat-moderation [data-chat-confirm] { background: var(--action); color: white; }

.chat-sound {
  display:grid; place-items:center; width:32px; height:32px; min-height:32px;
  padding:0; font-size:14px; line-height:1; border-radius:7px;
}
.chat-message-join { color: var(--quiet); background: color-mix(in srgb, var(--raised) 65%, transparent); }
.chat-message-join p { font-size: 12px; }

html.chat-account-open {
  overflow: hidden;
  overscroll-behavior: none;
  scrollbar-gutter: stable;
}
.chat-account-open > body {
  position: fixed;
  inset: var(--chat-page-offset) 0 auto;
}
.chat-account-window {
  box-sizing: border-box;
  width: min(460px, calc(100% - 24px));
  height: min(calc(var(--account-height, 360px) + 2px), calc(100dvh - 24px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink);
}
.chat-account-window-login {
  width: min(420px, calc(100% - 24px));
  --account-height: 340px;
}
.chat-account-window-register { width: min(560px, calc(100% - 24px)); --account-height: 640px; }
.chat-account-window::backdrop { background: #0009; }
.chat-account-window iframe { display: block; width: 100%; height: 100%; border: 0; }
.chat-account-close {
  position: absolute; z-index: 1; top: 8px; right: 16px;
  width: 32px; height: 32px; padding: 0; font-size: 20px;
}
@media (pointer: coarse) {
  .chat-account-close { width: 40px; height: 40px; right: 10px; }
}
.chat-account-embedded { background: var(--surface); }
html:has(> .chat-account-embedded) { overscroll-behavior: contain; }
.chat-account-embedded::before { display: none; }
.chat-account-embedded .chat-account-main { padding: 42px clamp(16px, 5vw, 28px) 24px; }
.chat-account-embedded .chat-profile { padding: 14px 16px 16px; }
.chat-account-embedded .chat-profile-cover { padding-right: 40px; }
.chat-account-embedded .chat-account-card {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}
.chat-account-register { max-width: 560px; }
.chat-account-field { display: grid; gap: 5px; }
.chat-account-passwords {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
.chat-account-register .chat-account-form > p { color: var(--quiet); margin: 0; }
:is(.chat-account-login, .chat-account-register) .chat-account-form > .chat-button { justify-self: stretch; }
:is(.chat-account-login, .chat-account-register) .chat-account-links { justify-content: center; }
@media (max-width: 440px) {
  .chat-account-passwords { grid-template-columns: minmax(0, 1fr); }
}
