:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --soft: #eef2f5;
  --line: #d8dee5;
  --text: #17202a;
  --muted: #657283;
  --brand: #176b87;
  --brand-soft: #d9ecf2;
  --surface-muted: #f8fafc;
  --ok: #1f7a4d;
  --warn: #a45d14;
  --danger: #b33a3a;
  --danger-soft: #f5dddd;
  --shadow: 0 16px 34px rgba(23, 32, 42, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 42px;
  max-height: 160px;
  resize: vertical;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.muted {
  color: var(--muted);
}

.auth-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.auth-panel p,
.topbar p {
  margin: 6px 0 0;
}

.stack-form,
.inline-form {
  display: grid;
  gap: 12px;
}

.stack-form {
  margin-top: 20px;
}

.narrow-form {
  max-width: 460px;
}

.inline-form {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) auto;
  align-items: end;
}

.stack-form label,
.inline-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.stack-form button,
.inline-form button,
.primary-btn {
  min-height: 38px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
}

.ghost-btn,
.icon-btn {
  min-height: 36px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
  padding: 0 12px;
}

.danger-btn {
  min-height: 36px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0 12px;
}

.form-error,
.warn-text {
  margin: 0;
  color: var(--danger);
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100dvh;
}

.admin-shell.is-chat {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --soft: #f3f5f6;
  --line: #e4e9e7;
  --text: #28332f;
  --muted: #687871;
  --brand: #187c69;
  --brand-soft: #e4f1ec;
  --surface-muted: #fbfcfc;
  --shadow: 0 12px 32px rgba(28, 52, 43, 0.12);
  grid-template-columns: 66px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  color: var(--text);
  letter-spacing: 0;
}

.admin-shell.is-chat .admin-sidebar {
  position: static;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  background: #f5f7f8;
  padding: 22px 8px 16px;
  overflow-y: auto;
}

.admin-shell.is-chat .brand {
  position: relative;
  display: grid;
  width: 42px;
  min-height: 34px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--brand);
}

.admin-shell.is-chat .brand .ui-icon {
  width: 28px;
  height: 28px;
  color: var(--brand);
}

/* Keep rail labels available to assistive technology. */
.admin-shell.is-chat .nav-label,
.admin-shell.is-chat .brand strong,
.admin-shell.is-chat .brand > span:not(.ui-icon) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.admin-sidebar nav button {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-shell.is-chat nav {
  display: flex;
  width: 100%;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: visible;
}

.admin-shell.is-chat nav button {
  position: relative;
  width: 42px;
  height: 42px;
  min-height: 42px;
  flex: 0 0 auto;
  justify-content: center;
  padding: 0;
}

.admin-shell.is-chat nav button:last-child {
  margin-top: auto;
}

.rail-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.rail-logout:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.admin-shell.is-chat :is(button, a):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.admin-sidebar {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 14px;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

nav button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 10px;
}

nav button:hover,
nav button.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100dvh;
}

.admin-shell.is-chat .workspace {
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

/* Status and account actions live in the chat list header and rail. */
.admin-shell.is-chat .topbar {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 16px 20px;
}

.topbar > div:first-child {
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-hint {
  max-width: 240px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.steam-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
}

.steam-badge[data-status="online"] {
  background: #dff1e8;
  color: var(--ok);
}

.steam-badge[data-status="waiting_guard"],
.steam-badge[data-status="logging_in"],
.steam-badge[data-status="reconnecting"] {
  background: #f6ead8;
  color: var(--warn);
}

.steam-badge[data-status="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.content {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.content.chat-content {
  overflow: hidden;
  padding: 0;
}

.feedback {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 9px 20px;
}

.feedback[data-tone="ok"] {
  color: var(--ok);
}

.feedback[data-tone="warn"] {
  color: var(--warn);
}

.feedback[data-tone="error"] {
  color: var(--danger);
}

.feedback[hidden] {
  display: none;
}

.chat-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 18;
  display: flex;
  max-width: min(420px, calc(100vw - 40px));
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 10px 10px 14px;
}

.toast-close,
.dialog-close {
  display: grid;
  width: 32px;
  height: 32px;
  min-height: 0;
  flex: 0 0 32px;
  border-radius: 6px;
  background: transparent;
  color: currentColor;
  padding: 0;
  place-items: center;
}

.ui-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

.icon-arrow-left { mask-image: url('/icons/arrow-left.svg'); }
.icon-image { mask-image: url('/icons/image.svg'); }
.icon-link { mask-image: url('/icons/link.svg'); }
.icon-paperclip { mask-image: url('/icons/paperclip.svg'); }
.icon-plus { mask-image: url('/icons/plus.svg'); }
.icon-search { mask-image: url('/icons/search.svg'); }
.icon-send { mask-image: url('/icons/send.svg'); }
.icon-smile { mask-image: url('/icons/smile.svg'); }
.icon-x { mask-image: url('/icons/x.svg'); }
.icon-panel-right { mask-image: url('/icons/panel-right.svg'); }
.icon-messages-square { mask-image: url('/icons/messages-square.svg'); }
.icon-gamepad-2 { mask-image: url('/icons/gamepad-2.svg'); }
.icon-users { mask-image: url('/icons/users.svg'); }
.icon-settings-2 { mask-image: url('/icons/settings-2.svg'); }
.icon-shield { mask-image: url('/icons/shield.svg'); }
.icon-scroll-text { mask-image: url('/icons/scroll-text.svg'); }
.icon-log-out { mask-image: url('/icons/log-out.svg'); }
.icon-external-link { mask-image: url('/icons/external-link.svg'); }
.icon-copy { mask-image: url('/icons/copy.svg'); }

.steam-view,
.users-view,
.steam-accounts-view,
.audit-view,
.account-view {
  display: grid;
  gap: 16px;
}

.users-view {
  grid-template-columns: minmax(300px, 0.8fr) minmax(520px, 1.2fr);
  align-items: start;
}

.panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.panel-title {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.panel .stack-form {
  margin-top: 0;
}

.toolbar-panel {
  align-self: start;
}

.list-panel {
  grid-column: 1 / -1;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0;
}

.form-panel,
.status-note-panel {
  max-width: 720px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-filters {
  grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.65fr) minmax(120px, 0.65fr) auto;
}

.user-create {
  grid-template-columns: minmax(150px, 0.9fr) minmax(150px, 0.9fr) minmax(160px, 0.9fr) minmax(130px, 0.7fr) minmax(210px, 1.2fr) auto;
}

.steam-account-login {
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(120px, 0.7fr) auto;
}

.audit-filters {
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.8fr) auto;
  max-width: 760px;
}

.status-panel {
  display: grid;
  gap: 4px;
  max-width: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.status-panel strong {
  font-size: 20px;
}

.user-table,
.account-table,
.audit-table {
  display: grid;
  gap: 8px;
}

.user-row,
.account-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, auto);
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 16px;
}

.user-row > div:first-child,
.account-row > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-row strong,
.user-row span,
.account-row strong,
.account-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-detail {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.detail-block,
.grant-grid {
  display: grid;
  gap: 8px;
  align-content: start;
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 10px;
}

.detail-block h3,
.grant-grid h3 {
  margin: 0;
  font-size: 14px;
}

.session-row,
.check-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(220px, 1.2fr) auto;
  gap: 8px;
  align-items: center;
}

.grant-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grant-grid h3,
.grant-grid .empty,
.grant-grid .primary-btn {
  grid-column: 1 / -1;
}

.check-row {
  grid-template-columns: auto minmax(0, 1fr);
  justify-content: start;
  color: var(--text);
}

.check-row input {
  width: auto;
}

.audit-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(300px, 1fr) minmax(260px, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.audit-row code {
  overflow: auto;
  border-radius: 6px;
  background: var(--soft);
  padding: 8px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 640px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.chat-layout {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--surface);
}

.chat-layout[data-details-open="true"] {
  grid-template-columns: 300px minmax(0, 1fr) 252px;
}

.chat-lists,
.thread {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.chat-lists {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.chat-list-head {
  display: grid;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 20px 18px 0;
}

.chat-account {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 4px 0 12px;
  text-align: left;
}

.chat-account:hover {
  background: var(--soft);
}

.chat-account > .ui-icon {
  color: var(--brand);
}

.chat-account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 5px;
}

.chat-account-copy strong {
  font-size: 16px;
  font-weight: 650;
}

.chat-account-copy :is(strong, span) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-account-copy span {
  color: var(--muted);
  font-size: 12px;
}

.chat-account-copy [data-status="online"] {
  color: var(--ok);
}

.chat-account-copy :is([data-status="waiting_guard"], [data-status="logging_in"], [data-status="reconnecting"]) {
  color: var(--warn);
}

.chat-account-copy [data-status="error"] {
  color: var(--danger);
}

.chat-list-head .steam-badge {
  justify-self: start;
  max-width: 100%;
  min-height: 24px;
  border-radius: 4px;
  font-size: 11px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.chat-list-head > .steam-badge {
  margin-bottom: 12px;
}

.chat-list-title {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-list-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.new-chat-btn {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  padding: 0 10px;
}

.new-chat-btn .ui-icon {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.chat-search {
  position: relative;
  display: block;
}

.chat-search .ui-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  z-index: 1;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
}

.chat-search input {
  height: 36px;
  background: var(--surface-muted);
  padding: 0 10px 0 34px;
}

.chat-search input::-webkit-search-cancel-button {
  cursor: pointer;
}

.chat-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chat-tabs button {
  min-width: 0;
  min-height: 40px;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 2px 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.chat-tabs button:hover {
  color: var(--text);
}

.chat-tabs button.is-active {
  border-bottom-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.conversation-list {
  min-height: 0;
  overflow: auto;
  padding: 8px 10px 12px;
}

.conversation-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.list-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 76px;
  margin: 3px 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 14px 10px;
  text-align: left;
}

.list-item:hover {
  background: var(--soft);
}

.list-item.is-active {
  background: var(--brand-soft);
}

.list-item:focus-visible,
.chat-tabs button:focus-visible,
.new-chat-btn:focus-visible,
.composer-tool:focus-visible,
.send-btn:focus-visible,
.thread-back:focus-visible,
.attachment-action:focus-visible,
.toast-close:focus-visible,
.dialog-close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.online-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ok);
}

.item-body {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
}

.item-title {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.item-title strong,
.item-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-title time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.item-preview {
  color: var(--muted);
  font-size: 12px;
}

.thread {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.thread-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 80px;
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
}

.thread-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.details-toggle,
.friend-details-head button {
  display: grid;
  width: 38px;
  height: 38px;
  min-height: 0;
  flex: 0 0 auto;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  place-items: center;
}

.details-toggle:hover,
.details-toggle[aria-expanded="true"],
.friend-details-head button:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.friend-details {
  z-index: 13;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-muted);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.friend-details-head {
  display: flex;
  min-height: 80px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.friend-details-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.friend-profile {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 18px;
  text-align: center;
  overflow-wrap: anywhere;
}

.friend-profile .friend-avatar {
  position: relative;
  display: grid;
  width: 66px;
  height: 66px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  overflow: hidden;
  font-size: 26px;
  font-weight: 700;
  place-items: center;
}

.friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.friend-profile h3 {
  max-width: 100%;
  margin: 4px 0 0;
  font-size: 18px;
}

.friend-profile p {
  max-width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.friend-facts {
  border-top: 1px solid var(--line);
  padding: 20px;
}

.friend-facts dl,
dl.friend-facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.friend-facts dt {
  color: var(--muted);
  font-size: 12px;
}

.friend-facts dd {
  min-width: 0;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.friend-profile-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 20px 20px;
  border-top: 1px solid var(--line);
  color: var(--brand);
  padding: 12px 0;
  font-size: 12px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.friend-profile-link:hover {
  text-decoration: underline;
}

.friend-details-backdrop {
  display: none;
}

.thread-back {
  display: none;
  width: 38px;
  height: 38px;
  min-height: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  place-items: center;
}

.thread-avatar {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  place-items: center;
}

.thread-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thread-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.thread-identity strong,
.thread-identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-tools {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 16px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.history-actions input {
  width: 210px;
  max-width: 100%;
  height: 34px;
}

.history-actions button {
  min-height: 34px;
  font-size: 12px;
}

.storage-health {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.conversations-more {
  width: 100%;
  margin-top: 8px;
}

.messages {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  padding: 24px 32px;
  scrollbar-width: thin;
  scrollbar-color: #dce5e0 transparent;
  overscroll-behavior: contain;
}

.thread-empty {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.empty.small {
  padding: 10px;
  font-size: 12px;
}

.msg-row {
  display: grid;
  min-width: 0;
  justify-items: start;
  margin: 0 0 20px;
}

.msg-row.is-self {
  justify-items: end;
}

.bubble {
  min-width: 0;
  max-width: min(640px, 86%);
  border: 1px solid #eef1ef;
  border-radius: 0 8px 8px 8px;
  background: var(--soft);
  overflow: hidden;
}

.msg-row.is-self .bubble {
  border-color: #dfede6;
  border-radius: 8px 0 8px 8px;
  background: var(--brand-soft);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 9px 13px 0;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 7px 13px 11px;
  font-size: 13px;
  line-height: 1.8;
}

.message-content a {
  color: var(--brand);
}

.og-card {
  width: min(640px, 100%);
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  margin: 4px 0;
  overflow: hidden;
  white-space: normal;
}

.og-main {
  display: flow-root;
  padding: 8px;
}

.og-image-link {
  display: block;
  float: left;
  width: min(256px, 42%);
  aspect-ratio: 16 / 9;
  margin: 0 12px 8px 0;
  border-radius: 6px;
  background: var(--soft);
  overflow: hidden;
}

.og-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.og-title {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.og-title:hover {
  color: var(--brand);
  text-decoration: underline;
}

.og-description {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.og-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  padding: 4px 6px 4px 8px;
}

.og-domain {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--brand);
  font-size: 12px;
  letter-spacing: 0;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.og-copy-button {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  place-items: center;
}

.og-copy-button:hover,
.og-copy-button:focus-visible {
  background: var(--brand-soft);
  color: var(--brand);
  outline: none;
}

.og-copy-icon {
  position: relative;
  display: block;
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: translate(2px, 2px);
}

.og-copy-icon::before {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  background: var(--soft);
  content: '';
}

.emoticon {
  width: 28px;
  height: 28px;
  vertical-align: middle;
}

.sticker {
  width: 118px;
  height: 118px;
  object-fit: contain;
  vertical-align: middle;
}

.image-button {
  display: block;
  max-width: min(420px, 100%);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 10px;
}

.image-button img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
}

.bbcode-image-shell {
  display: block;
  max-width: 100%;
  margin: 4px 0;
}

.bbcode-image-button {
  width: 420px;
  max-width: 100%;
  max-height: 420px;
  overflow: hidden;
  cursor: zoom-in;
  padding: 0;
}

.bbcode-image {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.bbcode-image-fallback {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.composer {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 8px;
  background: var(--surface);
  padding: 10px 28px max(20px, env(safe-area-inset-bottom));
}

.offline-note {
  border-radius: 6px;
  background: #f6ead8;
  color: var(--warn);
  padding: 7px 10px;
  font-size: 12px;
}

.compose-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid #dfe5e2;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(24, 61, 48, 0.04);
  padding: 10px;
}

.compose-row:focus-within {
  border-color: var(--brand);
}

.composer-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
}

.compose-row > .send-btn {
  grid-column: 2;
  justify-self: end;
}

.composer-tool,
.send-btn {
  display: grid;
  width: 40px;
  height: 40px;
  min-height: 0;
  border-radius: 6px;
  padding: 0;
  place-items: center;
}

.composer-tool {
  background: transparent;
  color: var(--muted);
}

.composer-tool:hover,
.composer-tool[aria-expanded="true"] {
  background: var(--brand-soft);
  color: var(--brand);
}

.send-btn {
  width: 42px;
  height: 42px;
  background: var(--brand);
  color: #fff;
}

.compose-row textarea {
  grid-column: 1 / -1;
  grid-row: 1;
  height: 52px;
  min-height: 52px;
  max-height: min(160px, 24dvh);
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
  overflow-y: auto;
  padding: 4px 3px;
  line-height: 1.7;
}

.compose-row textarea:focus {
  box-shadow: none;
}

.compose-row textarea::placeholder {
  color: var(--muted);
}

.attachment-shell {
  position: relative;
  width: 40px;
  height: 40px;
}

.attachment-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 7;
  display: grid;
  width: 286px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.attachment-menu[hidden],
.image-url-form[hidden] {
  display: none;
}

.attachment-action {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.attachment-action:hover {
  background: var(--soft);
}

.image-url-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding: 8px 4px 2px;
}

.image-url-form input {
  height: 34px;
}

.image-url-form button {
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 10px;
}

.picker {
  position: absolute;
  left: 28px;
  bottom: calc(100% - 2px);
  z-index: 6;
  width: min(520px, calc(100% - 56px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.picker[hidden] {
  display: none;
}

.picker-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.picker-tabs button,
.picker-grid button {
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
}

.picker-tabs button {
  padding: 7px 10px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 6px;
  max-height: min(280px, 35dvh);
  overflow: auto;
  padding: 8px;
}

.picker-grid button {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 8px;
}

.picker-grid img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.picker-grid span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.new-chat-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 0;
}

.new-chat-dialog::backdrop {
  background: rgba(18, 25, 32, 0.45);
}

.dialog-head {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 10px 16px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 16px;
}

.new-chat-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.new-chat-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.new-chat-form .primary-btn {
  justify-self: end;
}

.drop-overlay {
  position: fixed;
  inset: 20px;
  display: none;
  place-items: center;
  z-index: 20;
  border: 2px dashed var(--brand);
  border-radius: 8px;
  background: rgba(244, 246, 248, 0.92);
  color: var(--brand);
  font-size: 22px;
  font-weight: 700;
}

.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 30;
  background: rgba(18, 25, 32, 0.88);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

@media (max-width: 1500px) {
  .users-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  .top-actions {
    flex-wrap: wrap;
  }

  .user-row,
  .account-row,
  .session-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .user-filters,
  .user-create,
  .steam-account-login,
  .audit-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form button,
  .user-filters button,
  .user-create button,
  .steam-account-login button,
  .audit-filters button {
    grid-column: auto;
  }

  .row-actions {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 1100px) {
  .chat-layout[data-details-open="true"] {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .friend-details {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(300px, calc(100vw - 48px));
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: -8px 0 28px rgba(28, 52, 43, 0.14);
  }

  .friend-details-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: rgba(28, 40, 35, 0.28);
    padding: 0;
    cursor: default;
  }
}

@media (max-width: 920px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-shell.is-chat {
    grid-template-rows: minmax(0, 1fr);
  }

  .admin-shell.is-chat .workspace {
    height: 100%;
  }

  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-rows: auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  nav {
    display: flex;
    gap: 6px;
    overflow: auto;
  }

  nav button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .chat-layout,
  .chat-layout[data-details-open="true"] {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .thread-head {
    padding: 12px 16px;
  }

  .messages {
    padding: 20px 16px;
  }

  .composer {
    padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  }

  .picker {
    left: 16px;
    width: calc(100% - 32px);
  }

  .bubble {
    max-width: 94%;
  }
}

@media (max-width: 700px) {
  .admin-shell.is-chat {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .admin-shell.is-chat .admin-sidebar {
    flex-direction: row;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .admin-shell.is-chat .brand {
    width: 34px;
  }

  .admin-shell.is-chat nav {
    min-width: 0;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    padding: 3px;
    scrollbar-width: thin;
  }

  .admin-shell.is-chat nav button {
    width: 44px;
    height: 44px;
  }

  .admin-shell.is-chat nav button:last-child {
    margin-top: 0;
    margin-left: auto;
  }

  .admin-shell.is-chat:has(.chat-layout[data-mobile-panel="thread"]),
  .admin-shell.is-chat[data-mobile-panel="thread"] {
    grid-template-rows: minmax(0, 1fr);
  }

  .admin-shell.is-chat:has(.chat-layout[data-mobile-panel="thread"]) .admin-sidebar,
  .admin-shell.is-chat[data-mobile-panel="thread"] .admin-sidebar {
    display: none;
  }

  .chat-layout,
  .chat-layout[data-details-open="true"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-layout:not([data-mobile-panel="thread"]) .thread,
  .chat-layout[data-mobile-panel="thread"] .chat-lists {
    display: none;
  }

  .chat-lists {
    border-right: 0;
  }

  .chat-list-head {
    gap: 12px;
    padding-top: 12px;
  }

  .thread-back {
    display: grid;
    width: 44px;
    height: 44px;
  }

  .thread-head {
    grid-template-columns: 44px 36px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 68px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .thread-avatar {
    width: 36px;
    height: 36px;
  }

  .thread-identity strong {
    font-size: 14px;
  }

  .thread-identity span {
    font-size: 11px;
  }

  .details-toggle,
  .friend-details-head button {
    width: 44px;
    height: 44px;
  }

  .messages {
    padding: 18px 12px;
  }

  .composer {
    padding: 8px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .compose-row {
    padding: 8px;
  }

  .composer-tool,
  .attachment-shell,
  .send-btn {
    width: 44px;
    height: 44px;
  }

  .friend-details-head {
    min-height: 68px;
    padding: 8px 14px;
  }

  .picker {
    left: 10px;
    width: calc(100% - 20px);
  }

  .attachment-menu {
    width: min(286px, calc(100vw - 88px));
    max-height: 45dvh;
    overflow-y: auto;
  }

  .chat-toast {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 640px) {
  .content {
    padding: 12px;
  }

  .content.chat-content {
    padding: 0;
  }

  .inline-form,
  .user-filters,
  .user-create,
  .steam-account-login,
  .audit-filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 14px 12px;
  }

  .panel {
    padding: 12px;
  }

  .user-row,
  .account-row,
  .audit-row {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .og-image-link {
    float: none;
    width: 100%;
    margin: 0 0 8px;
  }

  .bbcode-image-button {
    width: 100%;
  }
}
