#rbs-chat-host {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  color-scheme: dark;
  --chat-base: #0b111a;
  --chat-surface: #111b28;
  --chat-raised: #172434;
  --chat-edge: #2a3a4d;
  --chat-text: #e8eff8;
  --chat-muted: #a7b8cc;
  --chat-mint: #54e2b6;
  --chat-gold: #f4c778;
  font: 14px/1.45 Inter, system-ui, sans-serif;
  color: var(--chat-text);
}
#rbs-chat-host [hidden] { display: none !important; }
html.rbs-chat-lock, html.rbs-chat-lock body { overflow: hidden; overscroll-behavior: none; }
html.rbs-chat-lock #rbs-chat-host { pointer-events: auto; }
#rbs-chat-host button { cursor: pointer; font: inherit; }
.rbs-chat-launch {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  width: 54px;
  height: 54px;
  border: 1px solid var(--chat-mint);
  border-radius: 15px;
  background: var(--chat-mint);
  color: #07261e;
  box-shadow: 0 4px 20px #0008;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.rbs-chat-launch i {
  width: 27px;
  height: 20px;
  position: relative;
  border: 2px solid currentColor;
  border-radius: 8px;
}
.rbs-chat-launch i::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: -5px;
  width: 6px;
  height: 7px;
  background: var(--chat-mint);
  border-left: 2px solid currentColor;
  transform: skewY(-35deg);
}
.rbs-chat-unread {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 12px;
  background: #d82443;
  color: white;
  text-align: center;
  font: 700 12px/21px system-ui, sans-serif;
}
#rbs-chat-host .rbs-chat-reply-notice {
  position: absolute;
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 64px));
  left: max(16px, env(safe-area-inset-left));
  max-width: calc(100% - 32px);
  z-index: 1;
  pointer-events: auto;
  background: #422d16;
  color: #ffd89a;
  border-color: #b97e36;
}
#rbs-chat-host .rbs-chat-top .rbs-chat-reply-notice {
  position: static;
  font-size: 12px;
}
.rbs-chat-window {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.rbs-chat-shell {
  position: absolute;
  left: 16px;
  bottom: 16px;
  box-sizing: border-box;
  width: min(960px, 100% - 32px);
  height: min(690px, 100% - 32px);
  display: flex;
  flex-direction: column;
  background: var(--chat-base);
  border: 1px solid var(--chat-edge);
  border-radius: 14px;
  box-shadow: 0 12px 40px #0008;
  overflow: hidden;
  pointer-events: auto;
}
.rbs-chat-window[data-full] { pointer-events: auto; overscroll-behavior: none; }
.rbs-chat-window[data-full] .rbs-chat-scroll { overscroll-behavior: none; }
.rbs-chat-window[data-full] .rbs-chat-shell {
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.rbs-chat-top, .rbs-chat-panehead, .rbs-chat-tools, .rbs-chat-person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rbs-chat-top {
  padding: 12px 16px;
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-edge);
}
.rbs-chat-window:not([data-full]) .rbs-chat-top {
  cursor: move;
  touch-action: none;
  user-select: none;
}
.rbs-chat-top strong { font-size: 18px; line-height: 1.15; }
.rbs-chat-identity { display: flex; align-items: center; min-width: 0; gap: 10px; }
.rbs-chat-identity-text { display: grid; min-width: 0; gap: 3px; }
.rbs-chat-market-mark {
  flex: 0 0 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #2a675c;
  border-radius: 9px;
  background: #12332f;
  color: var(--chat-mint);
}
.rbs-chat-market-mark i {
  position: relative;
  width: 4px;
  height: 9px;
  border-radius: 1px;
  background: currentColor;
  transform: translateY(3px);
}
.rbs-chat-market-mark i::before {
  content: "";
  position: absolute;
  inset: -3px auto;
  left: 50%;
  width: 1px;
  background: currentColor;
}
.rbs-chat-market-mark i:nth-child(2) { height: 7px; transform: translateY(0); }
.rbs-chat-market-mark i:nth-child(3) { height: 11px; transform: translateY(-3px); }
.rbs-chat-channels { display: none; }
.rbs-chat-viewer { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--chat-muted); font-size: 12px; }
.rbs-chat-window-actions { display: flex; flex-shrink: 0; gap: 6px; }
.rbs-chat-resize {
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 1;
  touch-action: none;
}
.rbs-chat-resize::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 3px, #84b5ba 3px 4px);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.rbs-chat-resize[data-corner="nw"] { top: 0; left: 0; rotate: 180deg; cursor: nwse-resize; }
.rbs-chat-resize[data-corner="ne"] { top: 0; right: 0; rotate: -90deg; cursor: nesw-resize; }
.rbs-chat-resize[data-corner="sw"] { bottom: 0; left: 0; rotate: 90deg; cursor: nesw-resize; }
.rbs-chat-resize[data-corner="se"] { bottom: 0; right: 0; cursor: nwse-resize; }
#rbs-chat-host .rbs-chat-control {
  padding: 5px 8px;
  border: 1px solid var(--chat-edge);
  border-radius: 7px;
  background: var(--chat-raised);
  color: var(--chat-text);
}
#rbs-chat-host .rbs-chat-control:hover { background: #22344a; }
#rbs-chat-host .rbs-chat-control:disabled { opacity: .55; cursor: default; }
#rbs-chat-host .rbs-chat-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}
#rbs-chat-host button:focus-visible, #rbs-chat-host textarea:focus-visible, .rbs-chat-split:focus-visible {
  outline: 2px solid var(--chat-mint);
  outline-offset: -2px;
}
.rbs-chat-grid { display: flex; flex: 1; min-height: 0; min-width: 0; }
.rbs-chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0;
  background: var(--chat-base);
}
.rbs-chat-grid:not([data-max]) .rbs-chat-pane:first-child { flex: 0 0 var(--chat-split, 40%); }
.rbs-chat-split {
  flex: 0 0 10px;
  display: grid;
  place-items: center;
  cursor: col-resize;
  background: var(--chat-surface);
  border-inline: 1px solid var(--chat-edge);
  touch-action: none;
}
.rbs-chat-split::before {
  content: "";
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: #657d96;
}
.rbs-chat-split:hover::before, .rbs-chat-split:active::before { background: var(--chat-mint); }
#rbs-chat-host [data-room="admin"] { --chat-channel: var(--chat-gold); }
#rbs-chat-host [data-room="public"] { --chat-channel: var(--chat-mint); }
.rbs-chat-panehead {
  padding: 8px 14px;
  border-bottom: 1px solid var(--chat-edge);
  background: var(--chat-surface);
}
.rbs-chat-panehead strong, .rbs-chat-channels .rbs-chat-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rbs-chat-panehead strong::before, .rbs-chat-channels .rbs-chat-control::before {
  content: "";
  flex: 0 0 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-channel);
}
.rbs-chat-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  overscroll-behavior: contain;
  scrollbar-color: #40546d var(--chat-base);
}
.rbs-chat-empty {
  margin: 0;
  padding: 32px 12px;
  text-align: center;
  color: var(--chat-muted);
}
.rbs-chat-message {
  overflow-wrap: anywhere;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--chat-edge);
  border-radius: 10px;
  background: var(--chat-surface);
}
.rbs-chat-message[data-own] { background: #102623; border-color: #28574f; }
.rbs-chat-message[data-replied] { border-inline-start: 3px solid var(--chat-gold); }
.rbs-chat-message[data-jump] { outline: 2px solid var(--chat-gold); outline-offset: -2px; }
.rbs-chat-reply-group { display: flex; gap: 4px; }
.rbs-chat-reply-links {
  display: grid;
  gap: 4px;
  margin-top: 4px;
  max-height: 180px;
  overflow: auto;
}
.rbs-chat-reply-links button { text-align: left; overflow-wrap: anywhere; }
.rbs-chat-person { color: var(--chat-muted); font-size: 12px; }
.rbs-chat-person time { white-space: nowrap; font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.rbs-chat-byline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; min-width: 0; }
.rbs-chat-person strong { color: var(--chat-text); min-width: 0; }
.rbs-chat-role {
  border: 1px solid #6e5734;
  border-radius: 4px;
  padding: 0 5px;
  background: #2b251b;
  color: var(--chat-gold);
  font-weight: 600;
}
.rbs-chat-body { white-space: pre-wrap; margin: 6px 0; }
.rbs-chat-sticker { font-size: 36px; line-height: 1.2; }
.rbs-chat-quote { border-left: 2px solid #4b9c92; padding: 3px 7px; color: #b8cbd9; }
.rbs-chat-message img { display: block; max-width: min(100%, 320px); max-height: 240px; object-fit: contain; border-radius: 6px; }
.rbs-chat-image-preview { display: block; max-width: 100%; padding: 0; border: 0; background: transparent; }
.rbs-chat-gallery {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: min(1200px, calc(100% - 32px));
  height: min(840px, calc(100% - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #344858;
  border-radius: 14px;
  background: #101820;
  color: #e7eef7;
  pointer-events: auto;
}
.rbs-chat-gallery[open] { display: flex; flex-direction: column; }
#rbs-chat-host .rbs-chat-ban-dialog { width: min(460px, calc(100% - 24px)); height: fit-content; max-height: 80dvh; }
.rbs-chat-ban-content { overflow: auto; padding: 12px; display: grid; gap: 8px; }
.rbs-chat-ban-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rbs-chat-ban-row button { flex: none; }
.rbs-chat-gallery::backdrop { background: #000a; }
.rbs-chat-gallery-header, .rbs-chat-gallery-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #172532;
}
.rbs-chat-gallery-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
}
.rbs-chat-gallery-stage {
  overflow: hidden;
  touch-action: none;
  user-select: none;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  background: #0b1117;
}
.rbs-chat-gallery-stage[data-zoomed] { cursor: grab; }
.rbs-chat-gallery-stage[data-zoomed][data-dragging] { cursor: grabbing; }
.rbs-chat-gallery-stage img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; }
.rbs-chat-gallery-stage img:not([src]) { display: none; }
.rbs-chat-gallery-stage p { position: absolute; bottom: 8px; padding: 4px 10px; background: #101820; }
.rbs-chat-gallery-stage p:empty { display: none; }
.rbs-chat-gallery-strip { overflow: auto; padding: 8px; overscroll-behavior: contain; }
.rbs-chat-gallery-thumbnails { display: grid; gap: 8px; margin: 8px 0; }
#rbs-chat-host .rbs-chat-gallery-thumbnails button {
  display: grid;
  gap: 3px;
  min-width: 0;
  width: 100%;
  text-align: left;
  font-size: 11px;
}
.rbs-chat-gallery-thumbnails img { width: 100%; height: 64px; object-fit: cover; }
.rbs-chat-gallery-thumbnails span, .rbs-chat-gallery-thumbnails time {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.rbs-chat-gallery-thumbnails time { color: #a8c3d5; }
#rbs-chat-host .rbs-chat-gallery-thumbnails button[aria-pressed=true] { border-color: #65efc9; }
.rbs-chat-gallery-details { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.rbs-chat-gallery-details span { color: #a8c3d5; max-height: 3em; overflow: auto; }
.rbs-chat-gallery-footer a { text-decoration: none; white-space: nowrap; }
.rbs-chat-message a { color: #8ddaff; }
.rbs-chat-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
#rbs-chat-host .rbs-chat-actions button { font-size: .8125rem; }
#rbs-chat-host .rbs-chat-actions button[aria-pressed=true] { border-color: var(--chat-mint); }
.rbs-chat-compose { padding: 10px 12px; border-top: 1px solid var(--chat-edge); background: var(--chat-surface); }
.rbs-chat-editor {
  padding: 5px;
  border: 1px solid var(--chat-edge);
  border-radius: 10px;
  background: var(--chat-base);
}
.rbs-chat-editor:focus-within { border-color: #488a7c; }
.rbs-chat-compose textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
  min-height: 38px;
  max-height: 112px;
  border: 0;
  border-radius: 5px;
  padding: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
}
.rbs-chat-compose textarea::placeholder { color: var(--chat-muted); }
.rbs-chat-tools { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
#rbs-chat-host .rbs-chat-tools .rbs-chat-icon { width: 36px; height: 36px; }
.rbs-chat-tools svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
#rbs-chat-host .rbs-chat-tools [aria-expanded="true"] { border-color: var(--chat-mint); }
#rbs-chat-host .rbs-chat-tools .rbs-chat-send {
  margin-inline-start: auto;
  border-color: var(--chat-mint);
  background: var(--chat-mint);
  color: #09271f;
  font-weight: 700;
}
#rbs-chat-host .rbs-chat-tools .rbs-chat-send:hover:not(:disabled) { background: #8befd0; }
.rbs-chat-status, .rbs-chat-readonly { padding: 6px 12px; color: var(--chat-muted); }
.rbs-chat-status[data-error] { color: #ffabab; }
.rbs-chat-selection { margin-bottom: 5px; display: flex; justify-content: space-between; gap: 6px; overflow-wrap: anywhere; }
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .rbs-chat-gallery {
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .rbs-chat-gallery-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rbs-chat-gallery-strip { display: flex; align-items: center; gap: 8px; }
  .rbs-chat-gallery-strip > button { flex: none; }
  .rbs-chat-gallery-thumbnails { display: flex; margin: 0; }
  #rbs-chat-host .rbs-chat-gallery-thumbnails button { flex: 0 0 92px; width: 92px; }
  .rbs-chat-shell {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .rbs-chat-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "identity actions" "notice notice";
    gap: 0 12px;
    padding: 8px 12px;
    border: 0;
  }
  .rbs-chat-identity { grid-area: identity; }
  .rbs-chat-top strong { font-size: 1.15rem; line-height: 1.2; }
  .rbs-chat-viewer { font-size: .8125rem; line-height: 1.3; }
  .rbs-chat-window-actions { grid-area: actions; gap: 8px; }
  #rbs-chat-host .rbs-chat-top .rbs-chat-reply-notice { grid-area: notice; justify-self: start; margin-top: 8px; min-height: 44px; }
  .rbs-chat-channels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 12px 8px;
    background: var(--chat-surface);
    border-bottom: 1px solid var(--chat-edge);
  }
  #rbs-chat-host .rbs-chat-channels .rbs-chat-control {
    justify-content: center;
    min-height: 44px;
    padding: 6px;
    border-radius: 8px;
    color: var(--chat-muted);
    font-weight: 600;
  }
  #rbs-chat-host .rbs-chat-channels [aria-selected="true"] {
    border-color: var(--chat-channel);
    background: var(--chat-base);
    color: var(--chat-channel);
  }
  .rbs-chat-grid { flex-direction: column; }
  .rbs-chat-grid .rbs-chat-pane { flex: 1 1 0; }
  .rbs-chat-grid:not([data-max]) .rbs-chat-pane:first-child { flex: 1 1 0; }
  .rbs-chat-panehead, .rbs-chat-split { display: none; }
  .rbs-chat-scroll { padding: 12px; }
  .rbs-chat-body { font-size: 1rem; line-height: 1.45; margin: 5px 0; }
  .rbs-chat-person { align-items: baseline; font-size: .8125rem; }
  .rbs-chat-message img { max-width: 100%; max-height: min(46dvh, 380px); object-position: left center; }
  .rbs-chat-compose { padding: 8px 12px; }
  .rbs-chat-compose textarea { min-height: 44px; font-size: 1rem; line-height: 1.35; resize: none; }
  #rbs-chat-host .rbs-chat-shell .rbs-chat-icon { min-width: 44px; width: 44px; height: 44px; border-radius: 9px; }
  #rbs-chat-host .rbs-chat-shell .rbs-chat-control:active { filter: brightness(1.18); }
  #rbs-chat-host .rbs-chat-message .rbs-chat-actions button,
  #rbs-chat-host .rbs-chat-compose .rbs-chat-actions button { min-width: 44px; min-height: 44px; }
}
