html.root-redirecting body { display: none !important; }
:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1020;
  color: #eef2ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(80, 90, 230, .22), transparent 35%),
    radial-gradient(circle at bottom right, rgba(20, 180, 160, .16), transparent 35%),
    #0b1020;
}
.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.chat-shell { align-items: start; padding-top: 28px; }
.card {
  width: min(100%, 460px);
  padding: 30px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: rgba(18, 25, 48, .88);
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
  backdrop-filter: blur(12px);
}
.chat-card { width: min(100%, 900px); }
h1 { margin: 10px 0 8px; font-size: clamp(1.8rem, 5vw, 2.5rem); }
h2 { margin-top: 0; font-size: 1.15rem; }
.muted, .hint { color: #b9c2dd; line-height: 1.55; }
.hint { font-size: .9rem; }
.compact { margin-top: 4px; margin-bottom: 0; }
.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(112, 120, 255, .14);
  border: 1px solid rgba(136, 145, 255, .3);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
}
form { display: grid; gap: 15px; margin-top: 22px; }
label { display: grid; gap: 7px; font-weight: 650; font-size: .92rem; }
input, textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(5, 9, 23, .58);
  color: inherit;
  font: inherit;
  outline: none;
}
textarea { resize: vertical; min-height: 52px; max-height: 180px; }
input:focus, textarea:focus { border-color: #8d95ff; box-shadow: 0 0 0 3px rgba(126, 137, 255, .15); }
button {
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  background: #7f89ff;
  color: #080b18;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: rgba(255,255,255,.12); color: inherit; }
.hidden { display: none !important; }
.message {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(238, 91, 111, .14);
  border: 1px solid rgba(238, 91, 111, .35);
  line-height: 1.45;
}
.message.success {
  background: rgba(35, 190, 140, .14);
  border-color: rgba(35, 190, 140, .35);
}
.row { display: flex; gap: 16px; align-items: center; }
.between { justify-content: space-between; }
.panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: 14px;
  background: rgba(5, 9, 23, .42);
  border: 1px solid rgba(255,255,255,.1);
}
.chat-panel { padding: 14px; }
.messages {
  height: min(58vh, 560px);
  min-height: 330px;
  overflow-y: auto;
  padding: 8px;
  scroll-behavior: smooth;
}
.chat-message {
  width: min(82%, 650px);
  margin: 10px 0;
  padding: 11px 13px;
  border-radius: 14px 14px 14px 4px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.08);
}
.chat-message.own {
  margin-left: auto;
  border-radius: 14px 14px 4px 14px;
  background: rgba(127,137,255,.19);
  border-color: rgba(127,137,255,.25);
}
.chat-message p { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.chat-meta { display: flex; justify-content: space-between; gap: 18px; color: #cbd1ff; font-size: .78rem; }
.chat-form { grid-template-columns: 1fr auto; align-items: end; margin: 10px 0 0; }
.chat-form button { min-width: 92px; height: 52px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.users-list { margin: 0; padding-left: 20px; color: #cbd1ff; line-height: 1.8; }
details > summary { cursor: pointer; font-weight: 750; font-size: 1.05rem; }
hr { border: 0; border-top: 1px solid rgba(255,255,255,.1); margin: 26px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
code { color: #cbd1ff; word-break: break-word; }
@media (max-width: 700px) {
  .card { padding: 20px; }
  .chat-shell { padding: 10px; }
  .chat-header { align-items: flex-start; }
  .admin-grid { grid-template-columns: 1fr; }
  .messages { min-height: 55vh; }
  .chat-form { grid-template-columns: 1fr; }
  .chat-form button { width: 100%; }
}
.wide { max-width: 1180px; }
.room-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: stretch; }
.rooms-pane { border: 1px solid var(--border, #ddd); border-radius: 14px; padding: 14px; background: rgba(127,127,127,.04); }
.rooms-list { display: grid; gap: 8px; }
.room-button { width: 100%; text-align: left; background: transparent; border: 1px solid var(--border, #ddd); color: inherit; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.room-button.active { font-weight: 700; background: rgba(127,127,127,.14); }
.chat-pane { min-width: 0; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.checkbox-list { display: grid; gap: 6px; margin: 8px 0 14px; }
.checkbox-list.compact { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 8px 0; }
.checkbox-row { display: block; font-weight: 500; }
.checkbox-row.inline { display: inline-flex; align-items: center; gap: 6px; }
.users-list { display: grid; gap: 12px; }
.user-row { border: 1px solid var(--border, #ddd); border-radius: 12px; padding: 12px; }
.user-controls { display: grid; gap: 8px; margin-top: 10px; }
.pill { display: inline-block; font-size: .82rem; padding: 2px 8px; border-radius: 999px; background: rgba(127,127,127,.16); }
.muted-pill { opacity: .75; }
.link { border: 0; background: transparent; color: inherit; text-decoration: underline; padding: 0; cursor: pointer; font: inherit; }
.danger { color: #b00020; }
.chat-message.deleted { opacity: .68; font-style: italic; }
@media (max-width: 760px) { .room-layout, .admin-grid { grid-template-columns: 1fr; } }

/* Layout repair: full-width dashboard and readable admin controls */
.shell.wide {
  width: min(100%, 1240px);
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 24px;
  padding: 28px 24px 48px;
}
.shell.wide > .card {
  width: 100%;
  max-width: none;
}
.chat-card {
  min-height: min(760px, calc(100vh - 56px));
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.eyebrow {
  margin: 0;
  color: #cbd1ff;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 11px;
  background: rgba(238,91,111,.14);
  border: 1px solid rgba(238,91,111,.35);
}
.room-layout {
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 600px;
}
.rooms-pane,
.chat-pane {
  min-width: 0;
}
.rooms-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rooms-pane h2,
.chat-pane h2 {
  margin-bottom: 8px;
}
.chat-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.messages {
  height: auto;
  min-height: 430px;
  max-height: 62vh;
}
.chat-form {
  width: 100%;
}
.chat-message {
  max-width: 720px;
}

#admin-panel {
  padding: 28px;
}
#admin-panel > h2 {
  margin-bottom: 24px;
}
.admin-grid {
  grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr);
  gap: 28px;
  align-items: start;
}
.admin-grid form,
.hostname-form {
  margin-top: 0;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(5,9,23,.32);
}
.admin-grid h3,
.hostname-form h3 {
  margin: 0 0 16px;
}
select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.18);
  background: #111831;
  color: #eef2ff;
  font: inherit;
}
fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
}
legend {
  padding: 0 6px;
  color: #cbd1ff;
  font-weight: 700;
  font-size: .9rem;
}
.checkbox-list {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
}
.checkbox-row,
.checkbox-row.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: .92rem;
}
.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin: 0;
}
.users-list {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  margin-top: 12px;
}
.user-row {
  min-width: 0;
  background: rgba(5,9,23,.28);
}
.user-controls {
  gap: 12px;
}
.hostname-form {
  margin-top: 28px;
}
.danger {
  color: #ff718d;
}

@media (max-width: 900px) {
  .room-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .room-layout {
    min-height: 0;
  }
  .rooms-list {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .messages {
    min-height: 420px;
  }
}

@media (max-width: 600px) {
  .shell.wide {
    padding: 10px;
    gap: 14px;
  }
  .shell.wide > .card,
  #admin-panel {
    padding: 18px;
    border-radius: 14px;
  }
  .topbar {
    flex-direction: column;
  }
  .topbar #logout {
    width: 100%;
  }
  .chat-card {
    min-height: auto;
  }
  .messages {
    min-height: 52vh;
    max-height: none;
    padding-inline: 0;
  }
  .chat-message {
    width: 94%;
  }
  .users-list {
    grid-template-columns: 1fr;
  }
}

/* File/photo attachments */
.composer-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  cursor: pointer;
  font-weight: 750;
}
.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-summary {
  color: #b9c2dd;
  font-size: .86rem;
  overflow-wrap: anywhere;
}
.attachments {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.image-attachment,
.file-attachment {
  color: inherit;
  text-decoration: none;
}
.image-attachment {
  display: grid;
  gap: 7px;
}
.image-attachment img {
  display: block;
  max-width: min(100%, 420px);
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  object-fit: contain;
  background: rgba(0,0,0,.18);
}
.image-attachment span,
.file-attachment {
  color: #d7dcff;
  font-size: .88rem;
}
.file-attachment {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
  overflow-wrap: anywhere;
}
.file-attachment:hover,
.image-attachment:hover span {
  text-decoration: underline;
}
.file-icon {
  flex: 0 0 auto;
}
@media (max-width: 700px) {
  .composer-tools {
    display: grid;
    gap: 8px;
  }
  .file-picker {
    width: 100%;
  }
  .image-attachment img {
    max-height: 260px;
  }
}

/* Guest signup, contacts, direct chats, replies, and notifications */
.access-card { width: min(100%, 520px); }
.auth-tabs { margin-top: 20px; }
.tab-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(5, 9, 23, .36);
}
.tab-button {
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
}
.tab-button.active {
  background: #7f89ff;
  color: #080b18;
}
.code-line {
  margin: 8px 0 0;
  color: #cbd1ff;
  line-height: 1.5;
}
.code-line code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  letter-spacing: .08em;
  font-weight: 800;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.chat-layout {
  grid-template-columns: 290px minmax(0, 1fr);
}
.sidebar-pane {
  gap: 22px;
  overflow: hidden;
}
.contacts-section {
  display: grid;
  gap: 10px;
}
.compact-form {
  margin: 0;
  gap: 8px;
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.inline-form button {
  padding-inline: 14px;
}
.contact-button {
  display: grid;
  gap: 4px;
}
.contact-button small {
  color: #b9c2dd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
}
.direct-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.danger-button {
  color: #ffb4c1 !important;
  border: 1px solid rgba(255, 113, 141, .24) !important;
}
.reply-preview {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: 12px;
  margin: 0 0 10px;
  background: rgba(127,137,255,.13);
  border: 1px solid rgba(127,137,255,.24);
}
.reply-preview p {
  margin: 4px 0 0;
  color: #d7dcff;
  max-width: 76ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-quote {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid rgba(127,137,255,.75);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
  color: #d7dcff;
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 15px;
  border-radius: 13px;
  background: #111831;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  color: #eef2ff;
}
.file-picker.disabled {
  opacity: .55;
  cursor: not-allowed;
}
.file-picker.disabled input {
  pointer-events: none;
}
@media (max-width: 980px) {
  .chat-layout { grid-template-columns: 1fr; }
  .sidebar-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}
@media (max-width: 680px) {
  .sidebar-pane { grid-template-columns: 1fr; }
  .top-actions, .chat-heading-row, .direct-actions { width: 100%; }
  .top-actions, .chat-heading-row { flex-direction: column; }
  .top-actions button, .direct-actions button { width: 100%; }
  .inline-form { grid-template-columns: 1fr; }
  .reply-preview { flex-direction: column; }
  .reply-preview p { white-space: normal; }
}

/* Group invitations and member lists */
.create-room-box {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(5,9,23,.26);
}
.small-text {
  font-weight: 500;
  font-size: .82rem;
}
.group-actions {
  display: grid;
  grid-template-columns: minmax(240px, .9fr) minmax(280px, 1.1fr);
  gap: 14px;
  align-items: start;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(5,9,23,.24);
}
.room-invite-form {
  margin: 0;
}
.members-box {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(127,137,255,.16);
  border: 1px solid rgba(127,137,255,.22);
  color: #d7dcff;
  font-size: .82rem;
  overflow-wrap: anywhere;
}
.invite-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.05);
}
.invite-card small {
  display: block;
  margin-top: 3px;
  color: #b9c2dd;
}
.invite-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.invite-actions button {
  padding: 9px 10px;
}
.chat-message.system {
  width: fit-content;
  max-width: min(92%, 720px);
  margin-inline: auto;
  border-radius: 999px;
  text-align: center;
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.11);
  color: #cbd1ff;
}
.chat-message.system .chat-meta {
  justify-content: center;
}
.chat-message.system p {
  margin-top: 4px;
}
@media (max-width: 760px) {
  .group-actions {
    grid-template-columns: 1fr;
  }
}

/* Guest signup and admin limit controls */
.tab-button.disabled,
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.limits-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  align-items: end;
}
.limits-row label {
  min-width: 0;
}
.limits-row input[type="number"] {
  width: 100%;
}
.compact-limits {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
}
.admin-add-room {
  align-items: end;
}
.admin-add-room select {
  min-width: 0;
}

/* Compact admin rows, top action toast, and room management */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -18px);
  z-index: 100;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: #151d3a;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 18px 50px rgba(0,0,0,.38);
  color: #eef2ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast:not(.hidden) {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.success {
  border-color: rgba(35,190,140,.45);
  background: #102a2a;
}
.toast.error {
  border-color: rgba(255,113,141,.45);
  background: #2a1420;
}
.notice {
  display: none !important;
}
.group-actions {
  grid-template-columns: minmax(210px, .9fr) minmax(230px, 1fr) auto;
  align-items: start;
}
.room-management-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.room-management-actions button {
  padding: 10px 12px;
  white-space: nowrap;
}
.user-row {
  padding: 10px;
}
.user-controls {
  gap: 10px;
}
.user-controls > select,
.admin-add-room select,
.user-controls button,
.admin-add-room button {
  padding: 10px 12px;
}
.user-groups-note {
  margin: 0;
  font-size: .86rem;
  line-height: 1.35;
  color: #b9c2dd;
}
.admin-add-room {
  grid-template-columns: minmax(0, 1fr) auto;
}
@media (max-width: 900px) {
  .group-actions {
    grid-template-columns: 1fr;
  }
  .room-management-actions {
    justify-content: stretch;
  }
  .room-management-actions button {
    width: 100%;
  }
}
@media (max-width: 520px) {
  .admin-add-room {
    grid-template-columns: 1fr;
  }
}

/* Final compact room controls and top pop-down action notice */
.toast {
  position: fixed !important;
  top: 14px !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -22px) !important;
  z-index: 9999 !important;
  max-width: min(560px, calc(100vw - 28px));
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast:not(.hidden) {
  opacity: 1;
  transform: translate(-50%, 0) !important;
}
.group-actions {
  grid-template-columns: minmax(260px, .85fr) minmax(220px, 1fr) auto;
  gap: 10px;
  padding: 10px;
  min-height: auto;
}
.group-actions input,
.group-actions button {
  min-height: 42px;
}
.members-box strong {
  font-size: .95rem;
}
.member-chip {
  padding: 4px 7px;
  font-size: .78rem;
}
.pending-room-actions {
  display: grid;
  gap: 7px;
  padding: 9px;
  border-radius: 12px;
  border: 1px solid rgba(127,137,255,.24);
  background: rgba(127,137,255,.1);
}
.pending-room-actions p {
  margin: 0;
  color: #b9c2dd;
  font-size: .84rem;
  line-height: 1.35;
}
.compact-invite-actions,
.invite-actions {
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
}
.room-button {
  display: grid;
  gap: 2px;
}
.room-button small {
  color: #b9c2dd;
  font-size: .76rem;
}
.user-groups-note {
  display: none;
}
.user-row {
  padding: 9px;
}
.user-controls {
  gap: 8px;
}
@media (max-width: 900px) {
  .group-actions { grid-template-columns: 1fr; }
}


/* Bugfix release: no pending-room preview, compact users, visible viewport toast */
.toast {
  position: fixed !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -24px) !important;
  z-index: 2147483647 !important;
  max-width: min(560px, calc(100vw - 28px)) !important;
}
.toast:not(.hidden) {
  opacity: 1 !important;
  transform: translate(-50%, 0) !important;
}
.invite-card .invite-actions {
  grid-template-columns: repeat(2, minmax(80px, 1fr));
}
.group-actions {
  grid-template-columns: minmax(220px, .8fr) minmax(220px, 1fr) auto !important;
  gap: 8px !important;
  padding: 8px !important;
}
.group-actions .inline-form,
.admin-add-room {
  gap: 8px !important;
}
.members-box {
  min-width: 0;
}
.room-management-actions button,
.group-actions button {
  padding: 9px 11px !important;
}
.user-groups-note {
  display: flex !important;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.045);
  color: #cbd1ff;
  font-size: .84rem;
  line-height: 1.35;
}
.user-controls {
  gap: 8px !important;
}
.user-row {
  padding: 10px !important;
}
.user-controls > select,
.admin-add-room select,
.user-controls button,
.admin-add-room button {
  min-height: 38px;
  padding: 8px 10px !important;
}
@media (max-width: 900px) {
  .group-actions { grid-template-columns: 1fr !important; }
}


/* Compact group header + invite system-message update */
.chat-pane {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}
.group-actions {
  display: grid !important;
  grid-template-columns: minmax(220px, 0.85fr) minmax(180px, 1fr) auto !important;
  align-items: start !important;
  align-self: stretch !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 8px 10px !important;
  margin: 0 0 10px !important;
}
.group-actions.hidden { display: none !important; }
.room-invite-form,
.room-invite-form .inline-form {
  margin: 0 !important;
}
.members-box {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  min-height: 42px !important;
  padding: 0 !important;
}
.members-box strong {
  margin-right: 4px !important;
}
.member-chips {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
}
.member-chip {
  padding: 4px 8px !important;
  line-height: 1.2 !important;
}
.room-management-actions {
  align-self: start !important;
  align-items: center !important;
}
.messages {
  flex: 1 1 auto !important;
  min-height: 360px !important;
}
@media (max-width: 900px) {
  .group-actions {
    grid-template-columns: 1fr !important;
  }
  .members-box {
    align-items: flex-start !important;
  }
}

.member-remove {
  appearance: none;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.22);
  background: transparent;
  color: #ffb3c4;
  cursor: pointer;
  font: inherit;
  font-size: .76rem;
  font-weight: 800;
  margin-left: 6px;
  padding: 1px 0 1px 7px;
}
.member-remove:hover {
  color: #ffd5df;
  text-decoration: underline;
}
.user-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.user-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(127,137,255,.12);
  border: 1px solid rgba(127,137,255,.22);
  color: #d7dcff;
  overflow-wrap: anywhere;
}


/* Light mode support */
.access-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}
.theme-toggle {
  width: auto;
  min-width: 112px;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.1);
  color: inherit;
  border-radius: 999px;
  font-size: .9rem;
  line-height: 1;
}
.theme-toggle:hover { filter: brightness(1.08); }
body.theme-light {
  background:
    radial-gradient(circle at top left, rgba(99, 110, 255, .18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(14, 165, 140, .13), transparent 34%),
    #f4f7ff !important;
  color: #111827 !important;
}
body.theme-light .card,
body.theme-light .panel,
body.theme-light .admin-grid form,
body.theme-light .hostname-form,
body.theme-light .rooms-pane,
body.theme-light .chat-pane,
body.theme-light .create-room-box,
body.theme-light .group-actions,
body.theme-light .compact-limits,
body.theme-light .invite-card,
body.theme-light .reply-preview,
body.theme-light .pending-room-actions {
  background: rgba(255,255,255,.86) !important;
  border-color: rgba(31,41,55,.14) !important;
  box-shadow: 0 18px 60px rgba(15,23,42,.12) !important;
}
body.theme-light .card {
  backdrop-filter: blur(12px);
}
body.theme-light .muted,
body.theme-light .hint,
body.theme-light .small-text,
body.theme-light .room-button small,
body.theme-light .invite-card small,
body.theme-light .file-summary,
body.theme-light .user-groups-note,
body.theme-light .reply-preview p,
body.theme-light .pending-room-actions p {
  color: #536076 !important;
}
body.theme-light .eyebrow,
body.theme-light .chat-meta,
body.theme-light code,
body.theme-light legend,
body.theme-light .users-list {
  color: #4655a8 !important;
}
body.theme-light input,
body.theme-light textarea,
body.theme-light select {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: rgba(31,41,55,.18) !important;
}
body.theme-light input::placeholder,
body.theme-light textarea::placeholder {
  color: #7b8496 !important;
}
body.theme-light input:focus,
body.theme-light textarea:focus,
body.theme-light select:focus {
  border-color: #6672ff !important;
  box-shadow: 0 0 0 3px rgba(102,114,255,.16) !important;
}
body.theme-light button {
  background: #6672ff;
  color: #ffffff;
}
body.theme-light button.secondary,
body.theme-light .theme-toggle,
body.theme-light .file-picker,
body.theme-light .tab-button {
  background: rgba(17,24,39,.07) !important;
  color: #1f2937 !important;
  border-color: rgba(31,41,55,.12) !important;
}
body.theme-light .tab-button.active,
body.theme-light button:not(.secondary):not(.link):not(.member-remove):not(.danger-button) {
  background: #6672ff !important;
  color: #ffffff !important;
}
body.theme-light .danger-button {
  background: #fff1f3 !important;
  color: #b4233b !important;
  border: 1px solid rgba(180,35,59,.2) !important;
}
body.theme-light .link {
  background: transparent !important;
  color: #3340aa !important;
}
body.theme-light .room-button {
  border-color: rgba(31,41,55,.16) !important;
  background: rgba(255,255,255,.56) !important;
  color: #111827 !important;
}
body.theme-light .room-button.active {
  background: rgba(102,114,255,.14) !important;
  border-color: rgba(102,114,255,.35) !important;
}
body.theme-light .messages {
  background: transparent !important;
}
body.theme-light .chat-message {
  background: #ffffff !important;
  border-color: rgba(31,41,55,.12) !important;
  box-shadow: 0 10px 30px rgba(15,23,42,.08) !important;
}
body.theme-light .chat-message.own {
  background: #eef1ff !important;
  border-color: rgba(102,114,255,.26) !important;
}
body.theme-light .chat-message.system {
  background: #f0f3ff !important;
  border-color: rgba(102,114,255,.22) !important;
  color: #4b5695 !important;
}
body.theme-light .message-quote {
  background: rgba(17,24,39,.06) !important;
  color: #374151 !important;
}
body.theme-light .pill,
body.theme-light .badge,
body.theme-light .member-chip,
body.theme-light .user-group-chip {
  background: rgba(102,114,255,.12) !important;
  border-color: rgba(102,114,255,.25) !important;
  color: #3d4799 !important;
}
body.theme-light .member-remove {
  background: transparent !important;
  color: #b4233b !important;
  border-left-color: rgba(180,35,59,.22) !important;
}
body.theme-light .notice,
body.theme-light .message {
  background: #fff1f3 !important;
  border-color: rgba(180,35,59,.22) !important;
  color: #8f1f33 !important;
}
body.theme-light .message.success {
  background: #ecfdf5 !important;
  border-color: rgba(22,163,74,.24) !important;
  color: #166534 !important;
}
body.theme-light .toast {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: rgba(31,41,55,.16) !important;
  box-shadow: 0 20px 60px rgba(15,23,42,.18) !important;
}
body.theme-light .toast.success {
  background: #ecfdf5 !important;
  color: #14532d !important;
  border-color: rgba(22,163,74,.28) !important;
}
body.theme-light .toast.error {
  background: #fff1f3 !important;
  color: #8f1f33 !important;
  border-color: rgba(180,35,59,.26) !important;
}
body.theme-light hr,
body.theme-light fieldset {
  border-color: rgba(31,41,55,.14) !important;
}
body.theme-light .attachment-card,
body.theme-light .attachment-image,
body.theme-light .attachment-file {
  background: rgba(255,255,255,.74) !important;
  border-color: rgba(31,41,55,.14) !important;
  color: #111827 !important;
}
@media (max-width: 600px) {
  .access-top { align-items: flex-start; }
  .theme-toggle { min-width: 104px; }
}


/* Upload limits and login restriction controls */
.upload-defaults {
  margin: 8px 0 10px;
}
.upload-user-limits {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.user-row .danger-button {
  justify-self: start;
}
.hostname-form h4 {
  margin: 16px 0 8px;
}
body.theme-light .compact-limits,
body.theme-light .user-groups-note {
  background: rgba(17,24,39,.045) !important;
  border-color: rgba(31,41,55,.12) !important;
  color: #374151 !important;
}


/* Admin settings drawer and performance-oriented compact UI */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #eef2ff;
  font-weight: 750;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.13); }
.admin-panel {
  overflow: clip;
  animation: adminPanelIn .18s ease-out;
}
.admin-panel.hidden { display: none !important; }
.admin-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.admin-panel-heading h2 { margin-bottom: 0; }
.admin-panel-heading .secondary { flex: 0 0 auto; }
@keyframes adminPanelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.users-list {
  content-visibility: auto;
  contain-intrinsic-size: 640px;
}
.user-row, .chat-message, .room-button, .invite-card {
  contain: layout paint style;
}
.messages {
  overflow-anchor: none;
}
@media (max-width: 680px) {
  .admin-panel-heading { flex-direction: column; }
  .admin-panel-heading .secondary { width: 100%; }
  .icon-button { width: 100%; }
}
body.theme-light .icon-button {
  background: rgba(15,23,42,.06);
  border-color: rgba(15,23,42,.12);
  color: #172033;
}
body.theme-light .icon-button:hover { background: rgba(15,23,42,.1); }

/* Added moderation, pins, reactions, search, and invite-link UI */
.message-search-row {
  margin: 10px 0 12px;
}
.message-search-row input {
  width: 100%;
  max-width: none;
}
.chat-message.pinned {
  border-color: rgba(250, 204, 21, .55);
  background: linear-gradient(180deg, rgba(250, 204, 21, .11), rgba(255,255,255,.045));
}
.pin-badge,
.member-status,
.edited-marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  color: #fde68a;
  background: rgba(250, 204, 21, .14);
  border: 1px solid rgba(250, 204, 21, .25);
}
.member-status {
  color: #fca5a5;
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .22);
}
.edited-marker {
  margin-top: -4px;
  color: #cbd5e1;
  background: transparent;
  border: 0;
  padding-left: 0;
}
.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.reaction-chip {
  min-height: 0;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: inherit;
}
.reaction-chip.active {
  border-color: rgba(96, 165, 250, .65);
  background: rgba(96, 165, 250, .18);
}
.member-chip .member-remove.danger {
  border-color: rgba(248, 113, 113, .35);
  color: #fecaca;
}
#create-invite-link.hidden { display: none !important; }
#create-invite-link {
  align-self: flex-start;
  margin: 0 0 8px;
}
body.theme-light .chat-message.pinned {
  border-color: rgba(202, 138, 4, .35);
  background: linear-gradient(180deg, rgba(254, 240, 138, .55), rgba(255,255,255,.75));
}
body.theme-light .pin-badge {
  color: #854d0e;
  background: #fef3c7;
  border-color: rgba(202, 138, 4, .25);
}
body.theme-light .member-status {
  color: #991b1b;
  background: #fee2e2;
  border-color: rgba(185, 28, 28, .18);
}
body.theme-light .edited-marker {
  color: #64748b;
  background: transparent;
}
body.theme-light .reaction-chip {
  border-color: rgba(15,23,42,.12);
  background: rgba(15,23,42,.04);
}
body.theme-light .reaction-chip.active {
  border-color: rgba(37, 99, 235, .38);
  background: rgba(37, 99, 235, .1);
}
body.theme-light .member-chip .member-remove.danger {
  color: #991b1b;
  border-color: rgba(185, 28, 28, .2);
}

/* Light-mode polish: softer app surfaces and correctly styled navigation buttons */
body.theme-light {
  background:
    radial-gradient(circle at 6% 0%, rgba(99, 102, 241, .16), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(20, 184, 166, .11), transparent 34%),
    linear-gradient(180deg, #f4f7ff 0%, #eef3ff 100%) !important;
  color: #172033 !important;
}
body.theme-light .chat-card {
  background: rgba(248, 250, 255, .92) !important;
  border-color: rgba(100, 116, 139, .18) !important;
  box-shadow: 0 22px 70px rgba(15, 23, 42, .10) !important;
}
body.theme-light .rooms-pane {
  background: rgba(255, 255, 255, .86) !important;
  border-color: rgba(100, 116, 139, .18) !important;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .07) !important;
}
body.theme-light .chat-pane {
  background: linear-gradient(180deg, rgba(255,255,255,.70), rgba(245,248,255,.92)) !important;
  border: 1px solid rgba(100, 116, 139, .14) !important;
  border-radius: 16px !important;
  padding: 14px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8) !important;
}
body.theme-light .group-actions {
  background: rgba(255,255,255,.78) !important;
  border-color: rgba(100, 116, 139, .16) !important;
  box-shadow: none !important;
}
body.theme-light .messages {
  background: linear-gradient(180deg, #f8faff 0%, #f5f7ff 100%) !important;
  border: 1px solid rgba(100, 116, 139, .11) !important;
  border-radius: 14px !important;
}
body.theme-light .chat-form {
  padding: 10px !important;
  border: 1px solid rgba(100, 116, 139, .14) !important;
  border-radius: 14px !important;
  background: rgba(255,255,255,.78) !important;
}
body.theme-light .chat-form textarea {
  background: #ffffff !important;
  border-color: rgba(100, 116, 139, .20) !important;
}
body.theme-light .file-picker {
  background: #f1f5ff !important;
  border-color: rgba(100,116,139,.18) !important;
  color: #243047 !important;
}
body.theme-light .file-summary {
  color: #64748b !important;
}
body.theme-light .chat-message {
  background: rgba(255,255,255,.94) !important;
  border-color: rgba(100,116,139,.16) !important;
  box-shadow: 0 10px 28px rgba(15,23,42,.075) !important;
  color: #172033 !important;
}
body.theme-light .chat-message.own {
  background: #eef2ff !important;
  border-color: rgba(99,102,241,.28) !important;
}
body.theme-light .chat-message.system {
  background: #f3f6ff !important;
  border-color: rgba(99,102,241,.22) !important;
  color: #4b5ca6 !important;
  box-shadow: 0 10px 30px rgba(79,70,229,.08) !important;
}
body.theme-light .chat-meta {
  color: #52619b !important;
}
body.theme-light .chat-message p,
body.theme-light .message-quote {
  color: #243047 !important;
}

/* The global light button rule was making room/contact items look like primary buttons. */
body.theme-light .rooms-list .room-button,
body.theme-light button.room-button,
body.theme-light .contact-button,
body.theme-light .rooms-pane .room-button {
  background: #ffffff !important;
  color: #172033 !important;
  border: 1px solid rgba(100, 116, 139, .18) !important;
  box-shadow: 0 5px 16px rgba(15,23,42,.055) !important;
}
body.theme-light .rooms-list .room-button:hover,
body.theme-light button.room-button:hover,
body.theme-light .contact-button:hover,
body.theme-light .rooms-pane .room-button:hover {
  background: #f4f7ff !important;
  border-color: rgba(99,102,241,.30) !important;
  filter: none !important;
}
body.theme-light .rooms-list .room-button.active,
body.theme-light button.room-button.active,
body.theme-light .contact-button.active,
body.theme-light .rooms-pane .room-button.active {
  background: linear-gradient(180deg, #eef2ff, #e8edff) !important;
  border-color: rgba(99,102,241,.42) !important;
  color: #303b8f !important;
  box-shadow: 0 8px 22px rgba(99,102,241,.12) !important;
}
body.theme-light .room-button small,
body.theme-light .contact-button small {
  color: #64748b !important;
}
body.theme-light .room-button.active small,
body.theme-light .contact-button.active small {
  color: #4f5c9f !important;
}
body.theme-light .member-chip,
body.theme-light .user-group-chip,
body.theme-light .pill {
  background: #eef2ff !important;
  border-color: rgba(99,102,241,.22) !important;
  color: #3f4a9a !important;
}
body.theme-light .member-remove,
body.theme-light .member-remove.danger {
  background: transparent !important;
  color: #c02645 !important;
  border-left-color: rgba(190,18,60,.18) !important;
}
body.theme-light .danger-button {
  background: #fff1f2 !important;
  color: #be123c !important;
  border-color: rgba(190,18,60,.18) !important;
}
body.theme-light .danger-button:hover {
  background: #ffe4e8 !important;
  filter: none !important;
}
body.theme-light .create-room-box,
body.theme-light .compact-limits,
body.theme-light .invite-card,
body.theme-light .pending-room-actions,
body.theme-light .reply-preview,
body.theme-light .admin-grid form,
body.theme-light .hostname-form,
body.theme-light .user-row {
  background: rgba(255,255,255,.82) !important;
  border-color: rgba(100,116,139,.16) !important;
  box-shadow: 0 8px 26px rgba(15,23,42,.06) !important;
}
body.theme-light input,
body.theme-light textarea,
body.theme-light select {
  background: #ffffff !important;
  color: #172033 !important;
  border-color: rgba(100,116,139,.22) !important;
}
body.theme-light input::placeholder,
body.theme-light textarea::placeholder {
  color: #8a95a8 !important;
}
body.theme-light .topbar h1,
body.theme-light h2,
body.theme-light h3,
body.theme-light strong {
  color: #172033 !important;
}
body.theme-light .muted,
body.theme-light .hint,
body.theme-light .small-text {
  color: #64748b !important;
}
@media (max-width: 700px) {
  body.theme-light .chat-pane {
    padding: 10px !important;
  }
  body.theme-light .messages {
    border-radius: 12px !important;
  }
}

/* Composer edit mode */
.edit-preview {
  background: rgba(255, 191, 87, .14);
  border-color: rgba(255, 191, 87, .32);
}
.chat-form.editing-message textarea {
  border-color: rgba(255, 191, 87, .55);
  box-shadow: 0 0 0 3px rgba(255, 191, 87, .12);
}
.chat-form.editing-message button[type="submit"] {
  background: linear-gradient(135deg, #ffcf6b, #ff9f43);
  color: #1a1306;
}
body.theme-light .edit-preview {
  background: rgba(255, 244, 214, .92) !important;
  border-color: rgba(217, 119, 6, .24) !important;
}
body.theme-light .chat-form.editing-message textarea {
  border-color: rgba(217, 119, 6, .38) !important;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, .08) !important;
}
body.theme-light .chat-form.editing-message button[type="submit"] {
  background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
  color: #111827 !important;
}

/* Amoo bear login gate */
.bear-login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #a8ddff;
  transition: opacity 650ms ease, visibility 650ms ease;
}
.bear-login-gate iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #a8ddff;
}
body.login-gated .login-shell {
  opacity: 0;
  transform: translateY(18px) scale(.985);
  pointer-events: none;
  transition: opacity 450ms ease, transform 450ms ease;
}
body.login-unlocked .bear-login-gate {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
body.login-unlocked .login-shell {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: loginReveal 520ms ease both;
}
@keyframes loginReveal {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
