:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef3f7;
  --surface-hover: #e6eef5;
  --line: #d8e0e8;
  --line-strong: #bdc9d6;
  --text: #172033;
  --muted: #66758a;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #dff5f1;
  --primary-contrast: #ffffff;
  --secondary: #285f8f;
  --secondary-strong: #1f4d73;
  --secondary-soft: #e6f0f8;
  --active-bg: var(--secondary-soft);
  --active-text: var(--secondary-strong);
  --active-border: rgba(40, 95, 143, 0.24);
  --brand: var(--primary);
  --brand-strong: var(--primary-strong);
  --brand-soft: var(--primary-soft);
  --accent: #285f8f;
  --danger: #b42318;
  --danger-strong: #8a1c14;
  --danger-soft: #fff1ef;
  --badge-bg: #eef3f7;
  --badge-text: #475569;
  --badge-info-bg: #e6f0f8;
  --badge-info-text: #1f4d73;
  --badge-danger-bg: #b42318;
  --badge-danger-text: #ffffff;
  --overlay-backdrop: rgba(15, 23, 42, 0.38);
  --overlay-radius: 8px;
  --overlay-shadow: 0 20px 54px rgba(23, 32, 51, 0.18);
  --focus-ring: rgba(40, 95, 143, 0.28);
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.12);
  --shadow-soft: 0 10px 28px rgba(23, 32, 51, 0.08);
  --radius: 8px;
  --control-radius: 7px;
  --control-height: 38px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
.ghost-link {
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  cursor: pointer;
  font-weight: 650;
  min-height: var(--control-height);
  padding: 0 13px;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

button {
  background: var(--primary);
  color: var(--primary-contrast);
}

button:hover {
  background: var(--primary-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
.ghost-link:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

input[type="file"] {
  min-width: 0;
}

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

h1,
h2,
p {
  margin: 0;
}

.auth-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-panel {
  width: min(920px, 100%);
  display: grid;
  gap: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark,
.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand-mark {
  width: 58px;
  height: 58px;
  font-size: 20px;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.avatar.has-image {
  background-position: center;
  background-size: cover;
}

.avatar-previewable {
  cursor: zoom-in;
}

.avatar-previewable:focus-visible {
  outline: 3px solid rgba(46, 91, 255, 0.32);
  outline-offset: 3px;
}

.auth-panel h1 {
  font-size: 42px;
  letter-spacing: 0;
}

.auth-panel p,
.column-header span,
.chat-header span,
.meta {
  color: var(--muted);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.auth-grid.auth-grid-login-only {
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
}

.form-stack {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.form-stack h2,
.panel h2,
.column-header h2,
.chat-header h2 {
  font-size: 16px;
}

.form-stack label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.verification-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.verification-code-button {
  min-width: 104px;
  white-space: nowrap;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  min-height: 18px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
  min-height: 22px;
  overflow-wrap: anywhere;
}

.error-text:not(:empty) {
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: var(--control-radius);
  background: var(--danger-soft);
  padding: 8px 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 340px 300px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar,
.conversation-column,
.chat-column {
  min-height: 0;
  background: var(--surface);
}

.sidebar,
.conversation-column {
  border-right: 1px solid var(--line);
}

.sidebar {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar-header,
.column-header,
.chat-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.chat-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.chat-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 10px;
}

.chat-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 10px;
  background: linear-gradient(135deg, #ecfeff, #e0f2fe);
  color: var(--active-text);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.chat-avatar.group-avatar {
  border-color: rgba(37, 99, 235, 0.2);
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  color: #1d4ed8;
}

.chat-avatar.empty-avatar {
  background: var(--surface-strong);
  color: var(--muted);
}

.chat-avatar.has-image {
  color: transparent;
  background: #e2e8f0;
}

.chat-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-heading h2,
.chat-heading span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-header-button,
.mobile-panel-header {
  display: none;
}

.profile-block,
.header-actions,
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-block {
  min-width: 0;
}

.account-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

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

.header-actions {
  flex: 0 0 auto;
  gap: 6px;
}

.account-action {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
}

.pwa-install-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 10px;
}

.pwa-install-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.pwa-install-copy strong,
.pwa-install-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pwa-install-copy strong {
  font-size: 13px;
}

.pwa-install-copy span {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.pwa-install-copy small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pwa-install-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.pwa-install-panel[data-pwa-state="ready"],
.pwa-profile-card[data-pwa-state="ready"] {
  border-color: var(--active-border);
  background: var(--active-bg);
}

.pwa-install-panel[data-pwa-state="installed"],
.pwa-profile-card[data-pwa-state="installed"] {
  border-color: rgba(22, 163, 74, 0.24);
  background: #f0fdf4;
}

.chat-header-actions {
  flex: 0 0 auto;
}

.chat-detail-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
}

.profile-block strong {
  display: block;
}

.profile-block span,
.meta,
.chat-header span,
.column-header span {
  font-size: 12px;
}

.ghost-button,
.ghost-link,
.icon-button {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button {
  background: var(--secondary-soft);
  border-color: rgba(40, 95, 143, 0.22);
  color: var(--secondary-strong);
}

.ghost-button:hover,
.ghost-link:hover,
.icon-button:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.secondary-button:hover {
  background: #d8e9f5;
  border-color: rgba(40, 95, 143, 0.34);
  color: var(--secondary-strong);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
}

.contact-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 12px;
}

.contact-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 34px;
  border: 1px solid transparent;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  padding: 0 8px;
  white-space: nowrap;
}

.contact-tab:hover,
.contact-tab:focus-visible {
  background: #eaf1f7;
  color: var(--text);
}

.contact-tab.active {
  border-color: var(--active-border);
  background: var(--active-bg);
  color: var(--active-text);
}

.contact-tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--badge-info-bg);
  color: var(--badge-info-text);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  padding: 0 5px;
}

.contact-panel {
  min-width: 0;
}

.panel {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.panel-fill {
  align-content: start;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.create-group-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.compact-form {
  display: grid;
  gap: 8px;
}

.list,
.conversation-list {
  display: grid;
  gap: 8px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty-state,
.empty-loading {
  display: grid;
  place-items: center;
  min-height: 62px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
  text-align: center;
}

.empty-loading {
  grid-template-columns: auto minmax(0, max-content);
  justify-content: center;
  gap: 8px;
  border-style: solid;
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

.empty-loading::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--secondary);
  animation: state-pulse 1.1s ease-in-out infinite;
}

.empty-inline {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

@keyframes state-pulse {
  0%,
  100% {
    opacity: 0.36;
    transform: scale(0.82);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.list-item,
.conversation-item {
  width: 100%;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  text-align: left;
}

.friend-list-item {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.friend-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(40, 95, 143, 0.22);
  border-radius: 9px;
  background: linear-gradient(135deg, #e6f0f8, #f8fafc);
  color: var(--active-text);
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
}

.friend-avatar.has-image {
  color: transparent;
  background: #e2e8f0;
}

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

.friend-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.friend-copy strong,
.friend-copy .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-list-item .item-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.friend-more-button {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.conversation-column {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.conversation-list {
  align-content: start;
  grid-auto-rows: max-content;
  overflow: auto;
  gap: 0;
  scrollbar-color: var(--line-strong) var(--surface-soft);
  scrollbar-width: thin;
}

.conversation-list::-webkit-scrollbar {
  width: 10px;
}

.conversation-list::-webkit-scrollbar-track {
  background: var(--surface-soft);
}

.conversation-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid var(--surface-soft);
  border-radius: 999px;
}

.conversation-item {
  background: transparent;
  border-width: 0 0 1px;
  color: var(--text);
  border-radius: 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 72px;
  position: relative;
  text-align: left;
  width: 100%;
  padding: 14px 16px;
  contain: layout paint;
  contain-intrinsic-size: 72px;
}

.conversation-item::before {
  content: "";
  position: absolute;
  inset: 12px auto 12px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
}

.conversation-item.is-private::before {
  background: var(--active-border);
}

.conversation-item.is-group::before {
  background: #7c3aed;
}

.conversation-item.is-readonly::before {
  background: var(--muted);
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--active-bg);
}

.conversation-item.has-unread {
  background: #fff7ed;
}

.conversation-item.has-unread:hover,
.conversation-item.has-unread.active {
  background: #ffedd5;
}

.conversation-item.has-unread strong {
  color: #9a3412;
}

.conversation-item.pinned {
  background: #f8fbff;
}

.conversation-item.pinned:hover,
.conversation-item.pinned.active {
  background: #e8f3ff;
}

.conversation-item.muted strong {
  color: #475569;
}

.conversation-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 10px;
  background: linear-gradient(135deg, #ecfeff, #e0f2fe);
  color: var(--active-text);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.conversation-avatar.group-avatar {
  border-color: rgba(37, 99, 235, 0.2);
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  color: #1d4ed8;
}

.conversation-avatar.has-image {
  color: transparent;
  background: #e2e8f0;
}

.conversation-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conversation-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

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

.conversation-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conversation-title-line strong {
  min-width: 0;
}

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

.conversation-kind {
  min-width: 34px;
  height: 19px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  color: var(--badge-text);
  background: var(--badge-bg);
  font-size: 11px;
}

.conversation-kind.private-kind {
  color: var(--badge-info-text);
  background: var(--badge-info-bg);
  border-color: rgba(40, 95, 143, 0.22);
}

.conversation-kind.group-kind {
  color: #5b21b6;
  background: #f3e8ff;
  border-color: rgba(124, 58, 237, 0.2);
}

.conversation-kind.readonly-kind {
  color: var(--muted);
  background: #f8fafc;
  border-color: var(--line-strong);
}

.conversation-last {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta-rail {
  display: grid;
  justify-items: end;
  align-self: start;
  gap: 5px;
  min-width: 78px;
  max-width: 118px;
}

.conversation-time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.conversation-status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  max-width: 100%;
}

.ui-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.conversation-state-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.pin-badge {
  border: 1px solid rgba(40, 95, 143, 0.22);
  color: var(--badge-info-text);
  background: var(--badge-info-bg);
}

.mute-badge {
  border: 1px solid var(--line-strong);
  color: var(--badge-text);
  background: var(--badge-bg);
}

.conversation-controls {
  display: inline-flex;
  gap: 4px;
}

.conversation-toggle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
}

.conversation-toggle:hover {
  color: var(--brand-strong);
  border-color: #93c5fd;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--badge-danger-bg);
  color: var(--badge-danger-text);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  padding: 0 7px;
}

.conversation-item.muted .unread-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.item-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.chat-column {
  border-right: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  position: relative;
}

.chat-column > * {
  min-width: 0;
  max-width: 100%;
}

.history-tools {
  display: none;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
}

.app-shell.chat-tools-open .history-tools {
  display: grid;
}

.history-tools-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-tools-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  min-height: 32px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.segmented button.active {
  background: var(--active-bg);
  color: var(--active-text);
  border-color: var(--active-border);
}

.history-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.history-search input {
  min-width: 0;
}

@media (min-width: 761px) and (max-width: 1360px) {
  .history-tools {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .history-search {
    grid-column: 1 / -1;
    grid-template-columns: minmax(220px, 1fr) auto auto;
  }
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.message-actions button {
  min-width: 0;
}

.history-action-group {
  gap: 6px;
}

.history-action-group .ghost-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 650;
}

.danger-button {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.22);
  color: var(--danger);
}

.danger-button:hover {
  background: #ffe3df;
  border-color: rgba(180, 35, 24, 0.36);
  color: var(--danger-strong);
}

.messages {
  background: linear-gradient(180deg, #f7f9fb 0%, #eef3f5 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 18px;
}

.chat-drop-overlay {
  position: absolute;
  inset: 68px 0 0;
  z-index: 25;
  display: grid;
  place-items: center;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  background: rgba(241, 245, 249, 0.7);
  padding: 18px;
  transition: opacity 160ms ease-out, visibility 160ms ease-out;
}

.chat-drop-overlay[hidden] {
  display: none;
}

.chat-column.drag-over .chat-drop-overlay {
  visibility: visible;
  opacity: 1;
}

.chat-drop-card {
  width: min(340px, 100%);
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px dashed var(--active-border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 16px 18px;
  text-align: center;
}

.chat-drop-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--active-bg);
  color: var(--active-text);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.chat-drop-card strong {
  font-size: 16px;
}

.chat-drop-card span:not(.chat-drop-icon) {
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .chat-drop-overlay {
    transition: none;
  }

  .user-detail-panel {
    animation: none;
  }
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(620px, calc(100% - 140px));
}

.message-body {
  display: grid;
  gap: 4px;
  min-width: 0;
  position: relative;
}

.message-select-control {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 22px;
  flex: 0 0 30px;
  border-radius: 8px;
  cursor: pointer;
}

.message-select-control:hover,
.message-select-control:focus-within {
  background: rgba(40, 95, 143, 0.1);
}

.message-select {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--secondary);
}

.message-select:disabled {
  opacity: 0.35;
}

.message.me {
  align-self: flex-end;
}

.message.other {
  align-self: flex-start;
}

.message.grouped {
  margin-top: -4px;
}

.message.grouped .message-body {
  gap: 0;
}

.message.grouped .meta {
  display: none;
}

.message-avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--active-border);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--active-bg), #f8fafc);
  color: var(--active-text);
  font-size: 13px;
  font-weight: 800;
}

.message-avatar-spacer {
  margin-top: 0;
  visibility: hidden;
}

.message-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  word-break: break-word;
  box-shadow: 0 4px 14px rgba(23, 32, 51, 0.06);
}

.message.me .bubble {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.message .bubble.recalled,
.message.me .bubble.recalled {
  background: var(--surface-strong);
  border-color: var(--border);
  color: var(--muted);
  font-style: italic;
}

.message.status-sending .bubble {
  opacity: 0.78;
}

.message.status-failed .bubble {
  border-color: #f5b8b8;
}

.message-sticker .bubble,
.message.me.message-sticker .bubble {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  padding: 2px;
  box-shadow: none;
}

.sticker-message {
  display: block;
  width: auto;
  max-width: min(180px, 44vw);
  max-height: 180px;
  border-radius: var(--radius);
  object-fit: contain;
}

.message-status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  justify-content: flex-end;
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.message.other .message-status-line {
  justify-content: flex-start;
}

.message-status-text {
  white-space: nowrap;
}

.message-status-error {
  color: var(--danger);
  overflow-wrap: anywhere;
}

.message-status-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

.message.other .message-status-actions {
  margin-left: 0;
}

.message-status-actions .ghost-button {
  min-height: 30px;
  padding: 0 10px;
}

.message-status-actions .ghost-button.danger {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.22);
  color: var(--danger);
}

.attachment-failure {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  max-width: min(420px, 100%);
  padding: 7px 8px;
  border: 1px solid rgba(214, 82, 82, 0.24);
  border-radius: 8px;
  background: #fff7f7;
  color: var(--text);
}

.attachment-failure-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(198, 40, 40, 0.1);
  color: var(--danger);
  font-weight: 700;
}

.attachment-failure-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  text-align: left;
}

.attachment-failure-title {
  font-weight: 700;
  color: var(--danger);
}

.attachment-failure-reason {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.attachment-failure-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.attachment-failure-actions .ghost-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
}

.message-toolbar {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  padding: 3px;
  border: 1px solid rgba(189, 201, 214, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.98);
  transition: opacity 120ms ease, transform 120ms ease;
  visibility: hidden;
}

.message.other .message-toolbar {
  left: calc(100% + 8px);
}

.message.me .message-toolbar {
  right: calc(100% + 8px);
}

.message:hover .message-toolbar,
.message:focus .message-toolbar,
.message:focus-within .message-toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
  visibility: visible;
}

.messages.selection-mode .message-toolbar {
  display: none;
}

.message-tool-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.message-tool-button:hover,
.message-tool-button:focus-visible {
  background: var(--surface-strong);
  color: var(--text);
}

.message-tool-button.danger {
  color: var(--danger);
}

.reply-context {
  display: grid;
  gap: 2px;
  border-left: 3px solid rgba(79, 124, 255, 0.42);
  background: rgba(79, 124, 255, 0.08);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.message.me .reply-context {
  border-left-color: rgba(255, 255, 255, 0.54);
  background: rgba(255, 255, 255, 0.16);
}

.reply-context span {
  color: var(--muted);
}

.message.me .reply-context span {
  color: rgba(255, 255, 255, 0.78);
}

.load-more-messages {
  align-self: center;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.bubble img,
.bubble video {
  display: block;
  max-width: min(360px, 100%);
  max-height: 320px;
  border-radius: 6px;
}

.bubble video {
  width: min(420px, 100%);
  background: #111827;
}

.previewable-image {
  cursor: zoom-in;
}

.previewable-image:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.attachment-card {
  display: grid;
  gap: 8px;
  min-width: min(260px, 100%);
  max-width: 430px;
}

.attachment-preview {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.attachment-details {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 6px 9px;
  align-items: center;
  min-width: 0;
}

.attachment-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
}

.attachment-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.attachment-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.attachment-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.attachment-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.message.me .attachment-icon,
.message.me .media-download {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.message.me .attachment-meta {
  color: rgba(255, 255, 255, 0.78);
}

.video-fallback {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.message.me .video-fallback {
  color: rgba(255, 255, 255, 0.78);
}

.media-download {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 32px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.media-download:hover {
  background: #dfe8f0;
}

.message.me .media-download:hover {
  background: rgba(255, 255, 255, 0.24);
}

@media (min-width: 761px) {
  .attachment-details {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .attachment-actions {
    grid-column: auto;
    justify-content: flex-end;
  }
}

.file-link {
  color: inherit;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pending-file {
  display: inline-block;
}

.upload-progress {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  align-items: center;
  gap: 8px;
  max-width: min(320px, 100%);
  font-size: 12px;
  color: var(--muted);
}

.upload-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 120ms ease;
}

.upload-progress-text {
  white-space: nowrap;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
}

.composer-tools {
  display: grid;
  grid-template-columns: repeat(6, 40px);
  align-items: center;
  gap: 8px;
}

.composer-tools .icon-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
}

.emoji-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
  max-height: min(340px, 46dvh);
  overflow: hidden;
}

.emoji-panel-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.emoji-panel-tabs button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line);
}

.emoji-panel-tabs button.active {
  background: var(--active-bg);
  color: var(--active-text);
  border-color: var(--active-border);
}

.emoji-panel-body {
  min-height: 0;
  overflow: hidden;
}

.emoji-panel-body.is-scrollable {
  overflow: auto;
  padding-right: 2px;
}

.emoji-panel-body.is-paged {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.emoji-category-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.emoji-category-tab {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 9px;
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line);
}

.emoji-category-tab.active {
  background: var(--active-bg);
  color: var(--active-text);
  border-color: var(--active-border);
}

.emoji-page-viewport {
  flex: 1 1 auto;
  min-height: 164px;
  overflow: hidden;
  touch-action: pan-y;
}

.emoji-page-track {
  display: flex;
  height: 100%;
  transition: transform 180ms ease-out;
  will-change: transform;
}

.emoji-page {
  flex: 0 0 100%;
  min-width: 100%;
  height: 100%;
}

.emoji-grid,
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
}

.emoji-page-grid {
  grid-template-columns: repeat(8, 38px);
  grid-auto-rows: 38px;
  height: auto;
  align-content: start;
  justify-content: center;
}

.emoji-page-grid .emoji-choice {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.emoji-choice,
.sticker-choice,
.sticker-delete {
  background: var(--surface-soft);
  color: var(--text);
  border-color: transparent;
}

.emoji-choice,
.sticker-choice {
  display: inline-grid;
  place-items: center;
  width: 100%;
  min-height: 38px;
  padding: 0;
}

.emoji-choice {
  aspect-ratio: 1;
  font-size: 22px;
  line-height: 1;
}

.emoji-choice:hover,
.emoji-choice:focus-visible,
.sticker-choice:hover,
.sticker-choice:focus-visible {
  background: var(--surface-hover);
  border-color: var(--active-border);
}

.sticker-tile {
  position: relative;
}

.sticker-choice {
  aspect-ratio: 1;
}

.sticker-choice img {
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
}

.sticker-delete {
  position: absolute;
  top: -4px;
  right: -4px;
  display: none;
  width: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border-color: var(--line);
  border-radius: 999px;
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
}

.sticker-tile:hover .sticker-delete,
.sticker-tile:focus-within .sticker-delete {
  display: inline-grid;
  place-items: center;
}

.emoji-page-controls {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 28px;
}

.emoji-page-nav {
  min-width: 0;
  min-height: 28px;
  padding: 0;
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line);
}

.emoji-page-nav:disabled {
  color: var(--muted);
  background: var(--surface-soft);
  opacity: 0.55;
}

.emoji-page-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.emoji-page-dot {
  width: 7px;
  min-width: 7px;
  min-height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
}

.emoji-page-dot.active {
  width: 18px;
  background: var(--primary);
}

@media (prefers-reduced-motion: reduce) {
  .emoji-page-track {
    transition: none;
  }
}

.emoji-panel-status {
  margin: 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.composer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.reply-composer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--secondary);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px 10px;
}

.reply-composer[hidden] {
  display: none;
}

.reply-composer p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.reply-composer .ghost-button {
  min-height: 30px;
  padding: 0 10px;
  flex: 0 0 auto;
}

.composer-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.composer textarea {
  max-height: 120px;
  min-height: 40px;
  resize: none;
}

.send-button {
  min-width: 74px;
  min-height: 40px;
  padding: 0 16px;
}

.send-button:disabled {
  background: var(--surface-strong);
  color: var(--muted);
  border-color: var(--line);
  opacity: 1;
}

.send-button.is-ready {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.send-button.is-ready:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  padding: 0;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.account-action svg {
  width: 18px;
  height: 18px;
}

.icon-button.recording {
  border-color: var(--danger);
  color: var(--danger);
}

.attachment-audio audio,
.audio-message audio {
  width: min(320px, 100%);
  max-width: 100%;
}

.voice-recorder {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px 10px;
}

.voice-recorder[hidden] {
  display: none;
}

.voice-recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.12);
}

.voice-recorder-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}

.voice-recorder .ghost-button {
  min-height: 32px;
  padding: 0 10px;
}

.mobile-nav {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.profile-page {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 22px;
}

.profile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) repeat(2, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

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

.profile-card h2 {
  font-size: 16px;
}

.pwa-profile-card {
  align-content: start;
}

.profile-summary {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 26px;
}

.default-avatar-panel {
  display: grid;
  gap: 10px;
}

.default-avatar-panel h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.default-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}

.default-avatar-option {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  padding: 2px;
}

.default-avatar-option:hover,
.default-avatar-option:focus-visible {
  border-color: var(--secondary);
  outline: none;
}

.default-avatar-option.selected {
  border-color: var(--brand);
  background: var(--active-bg);
}

.default-avatar-option img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
}

.profile-facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-facts div {
  display: grid;
  gap: 3px;
}

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

.profile-facts dd {
  margin: 0;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--overlay-backdrop);
  padding: 18px;
}

.paste-dialog {
  width: min(460px, 100%);
  max-height: min(680px, calc(100dvh - 36px));
  display: grid;
  gap: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--overlay-radius);
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
  padding: 18px;
}

.paste-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.paste-dialog-head h2 {
  font-size: 18px;
}

.paste-dialog-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.paste-preview {
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.paste-preview.has-preview {
  display: block;
}

.paste-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #111827;
}

.paste-file-list {
  display: grid;
  gap: 8px;
}

.paste-file-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.paste-file-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--active-bg);
  color: var(--active-text);
  font-weight: 800;
}

.paste-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.forward-dialog label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.forward-dialog select {
  width: 100%;
}

.favorites-list {
  display: grid;
  gap: 10px;
}

.group-announcement-panel {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.group-announcement-panel strong {
  font-size: 13px;
}

.group-announcement-panel p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.group-announcement-panel p.empty-announcement {
  color: var(--muted);
}

.group-announcement-form {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.group-announcement-form textarea {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  resize: vertical;
}

.group-announcement-form label,
.group-members-dialog > * {
  min-width: 0;
  max-width: 100%;
}

.group-members-list {
  display: grid;
  gap: 8px;
}

.group-files-panel {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  gap: 8px;
}

.group-files-panel > strong {
  font-size: 13px;
}

.group-files-list {
  display: grid;
  gap: 8px;
}

.group-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.group-file-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.group-file-info strong,
.group-file-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.group-file-actions .ghost-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
  text-decoration: none;
}

.group-member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.group-member-item strong,
.group-member-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-member-role {
  border-radius: 999px;
  background: var(--badge-info-bg);
  color: var(--badge-info-text);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.group-member-muted {
  color: var(--danger);
}

.group-member-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.group-member-actions .ghost-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.group-invite-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.group-invite-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.group-invite-form select {
  width: 100%;
}

.favorite-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.favorite-content {
  color: var(--text);
  word-break: break-word;
}

.favorite-content a {
  color: var(--brand-strong);
  font-weight: 700;
}

.paste-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.message-action-dialog {
  width: min(360px, 100%);
}

.message-action-list {
  display: grid;
  gap: 8px;
}

.message-action-list .ghost-button {
  width: 100%;
  justify-content: flex-start;
  min-height: 42px;
}

.message-action-list .ghost-button.danger {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.22);
  color: var(--danger);
}

.user-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  justify-content: end;
  background: rgba(15, 23, 42, 0.24);
}

.user-detail-backdrop[hidden] {
  display: none;
}

.user-detail-panel {
  width: min(380px, calc(100vw - 28px));
  min-width: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  animation: userDetailSlideIn 180ms ease-out;
}

.user-detail-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
}

.user-detail-header h2 {
  margin: 0;
  font-size: 18px;
}

.user-detail-header span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.user-detail-back-button {
  font-size: 28px;
  line-height: 1;
}

.user-detail-body {
  min-width: 0;
  overflow-y: auto;
  padding: 22px 18px max(22px, env(safe-area-inset-bottom));
}

.user-detail-avatar {
  width: 96px;
  height: 96px;
  min-height: 96px;
  display: grid;
  place-items: center;
  margin: 2px auto 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--brand);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
}

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

.user-detail-avatar:disabled {
  cursor: default;
  opacity: 1;
}

.user-detail-heading {
  margin-bottom: 18px;
  text-align: center;
}

.user-detail-heading h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.user-detail-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.user-detail-facts {
  display: grid;
  gap: 0;
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.user-detail-facts div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
}

.user-detail-facts div + div {
  border-top: 1px solid var(--line);
}

.user-detail-facts dt {
  color: var(--muted);
  font-size: 13px;
}

.user-detail-facts dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.user-remark-form {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.user-remark-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.user-remark-actions,
.user-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.user-detail-actions button {
  width: 100%;
}

@keyframes userDetailSlideIn {
  from {
    transform: translateX(18px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.image-preview-backdrop {
  z-index: 50;
  place-items: stretch;
  padding: 0;
  background: #000;
}

.image-preview-dialog {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  color: #fff;
}

.image-preview-info {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 2;
  max-width: min(560px, calc(100vw - 28px));
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.72);
}

.image-preview-info h2 {
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-info p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.image-preview-actions {
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 10px;
}

.image-preview-action-button,
.image-preview-action-link {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(45, 45, 45, 0.88);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
}

.image-preview-action-button:hover,
.image-preview-action-button:focus-visible,
.image-preview-action-link:hover,
.image-preview-action-link:focus-visible {
  background: rgba(74, 74, 74, 0.94);
}

.image-preview-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.image-preview-original-button {
  font-size: 13px;
  letter-spacing: 0;
}

.image-preview-stage {
  min-height: 0;
  width: 100%;
  height: 100%;
}

.image-preview-canvas {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
}

.image-preview-canvas img {
  display: block;
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.12s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.image-preview-nav {
  font-size: 32px;
}

.image-preview-nav:disabled {
  opacity: 0.36;
}

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

.admin-shell:not(.is-authenticated) {
  grid-template-columns: minmax(0, 640px);
  justify-content: center;
}

.admin-shell:not(.is-authenticated) .admin-content {
  width: 100%;
  max-width: 640px;
}

.admin-sidebar {
  background: #172033;
  color: #fff;
  min-width: 0;
  padding: 22px;
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 18px;
}

.admin-sidebar p {
  color: #afbac8;
  margin: 0;
}

.admin-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.admin-nav a {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--control-radius);
  color: #dce6f2;
  font-size: 13px;
  font-weight: 750;
  padding: 0 10px;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.admin-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.admin-content {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
  padding: 22px;
  scroll-padding-top: 18px;
}

.admin-content > * {
  min-width: 0;
}

.admin-page {
  display: grid;
  gap: 18px;
  min-width: 0;
  animation: admin-page-in 180ms ease both;
}

@keyframes admin-page-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .admin-page { animation: none; }
}

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

.metric-card,
.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  padding: 16px;
}

.metric-card strong {
  display: block;
  font-size: 28px;
}

.admin-card {
  display: grid;
  gap: 12px;
}

.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.admin-section-head h2 {
  min-width: 0;
}

.admin-message-actions {
  flex: 0 0 auto;
}

.admin-message-actions .ghost-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.admin-confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--overlay-radius);
  box-shadow: var(--overlay-shadow);
  color: var(--text);
  padding: 0;
}

.admin-confirm-dialog::backdrop {
  background: var(--overlay-backdrop);
}

.admin-confirm-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.admin-confirm-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--danger);
  background: var(--danger-soft);
  font-weight: 900;
}

.admin-confirm-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.admin-confirm-copy h2,
.admin-confirm-copy p {
  margin: 0;
}

.admin-confirm-copy h2 {
  font-size: 17px;
  line-height: 1.25;
}

.admin-confirm-copy p {
  color: var(--muted);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.admin-confirm-detail {
  border: 1px solid rgba(180, 35, 24, 0.16);
  border-radius: var(--control-radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

.admin-confirm-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.admin-confirm-actions .ghost-button {
  min-height: 36px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-log-table {
  table-layout: fixed;
}

.admin-log-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-log-table th:first-child,
.admin-log-time-cell {
  width: 112px;
}

.admin-log-time-cell {
  color: var(--muted);
  white-space: nowrap;
}

.admin-log-time,
.admin-log-date,
.admin-log-person,
.admin-log-sub,
.admin-log-code {
  display: block;
  min-width: 0;
}

.admin-log-time {
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.admin-log-date,
.admin-log-sub,
.admin-log-code {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-log-person {
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-log-role {
  width: fit-content;
  margin-top: 5px;
  padding: 4px 7px;
  border: 1px solid rgba(40, 95, 143, 0.22);
  color: var(--badge-info-text);
  background: var(--badge-info-bg);
  font-size: 11px;
}

.admin-log-action {
  width: fit-content;
  padding: 5px 8px;
  font-size: 11px;
}

.admin-log-action.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(180, 35, 24, 0.22);
}

.admin-log-action.success {
  color: var(--primary-strong);
  background: var(--primary-soft);
  border: 1px solid rgba(19, 124, 73, 0.2);
}

.admin-log-action.info {
  color: var(--badge-info-text);
  background: var(--badge-info-bg);
  border: 1px solid rgba(40, 95, 143, 0.22);
}

.admin-log-action.neutral {
  color: var(--badge-text);
  background: var(--badge-bg);
  border: 1px solid var(--line-strong);
}

.admin-log-code {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.admin-log-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.admin-log-detail-list span {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  padding: 4px 7px;
  overflow-wrap: anywhere;
}

.admin-log-raw summary {
  color: var(--active-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.admin-log-raw code {
  display: block;
  max-width: 100%;
  margin-top: 6px;
  border-radius: var(--control-radius);
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  padding: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.settings-grid,
.admin-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.admin-message-filter {
  grid-template-columns: minmax(150px, 1.5fr) minmax(112px, 1fr) minmax(96px, 0.8fr) minmax(82px, 0.65fr) minmax(135px, 1.05fr) minmax(135px, 1.05fr) auto;
  gap: 8px;
}

.admin-message-filter label {
  min-width: 0;
}

.admin-message-filter input,
.admin-message-filter select {
  min-height: 34px;
  padding: 7px 9px;
}

.admin-message-filter button[type="submit"] {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.settings-grid .wide-field {
  grid-column: 1 / -1;
}

.reset-password-form {
  min-width: 220px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
}

.admin-user-actions {
  min-width: 220px;
  display: grid;
  gap: 8px;
}

.admin-user-actions > .ghost-button {
  width: fit-content;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  width: auto;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  .conversation-column {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    background: #fff;
  }

  .auth-shell {
    padding: 18px;
  }

  .auth-grid,
  .app-shell,
  .admin-shell,
  .admin-grid,
  .profile-grid,
  .settings-grid,
  .admin-filter {
    grid-template-columns: 1fr;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .auth-panel h1 {
    font-size: 34px;
  }

  .verification-row {
    grid-template-columns: 1fr;
  }

  .verification-code-button {
    width: 100%;
  }

  .app-shell {
    height: 100dvh;
    padding-bottom: 0;
    position: relative;
  }

  .app-shell.mobile-menu-open::after,
  .app-shell.chat-tools-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(15, 23, 42, 0.28);
  }

  .sidebar,
  .conversation-column,
  .chat-column {
    border-right: 0;
  }

  .app-shell [data-mobile-panel] {
    display: none;
  }

  .app-shell[data-mobile-view="contacts"] [data-mobile-panel="contacts"],
  .app-shell[data-mobile-view="conversations"] [data-mobile-panel="conversations"],
  .app-shell[data-mobile-view="chat"] [data-mobile-panel="chat"] {
    display: grid;
  }

  .chat-column {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .chat-header {
    min-height: 56px;
    padding: 8px 10px;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 9px;
  }

  .mobile-panel-header {
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
  }

  .mobile-panel-header h2 {
    font-size: 15px;
  }

  .mobile-panel-header span {
    display: block;
    max-width: 100%;
    color: var(--muted);
    font-size: 12px;
  }

  .pwa-install-panel {
    margin: 0 10px;
    gap: 8px;
    padding: 9px;
  }

  .pwa-install-button {
    min-width: 66px;
  }

  .chat-header h2 {
    font-size: 15px;
  }

  .chat-header span {
    display: block;
    max-width: 100%;
  }

  .mobile-header-button {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    background: var(--surface-strong);
    color: var(--text);
    font-size: 18px;
  }

  .conversation-column {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .group-announcement-form,
  .group-invite-form {
    grid-template-columns: 1fr;
  }

  .group-member-item {
    grid-template-columns: 1fr;
  }

  .group-file-item {
    grid-template-columns: 1fr;
  }

  .group-file-actions {
    justify-content: flex-start;
  }

  .group-member-actions {
    justify-content: flex-start;
  }

  .sidebar {
    grid-template-rows: none;
    grid-auto-rows: max-content;
    align-content: start;
  }

  .history-tools {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    grid-template-columns: 1fr;
    max-height: min(72dvh, 460px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--overlay-radius);
    box-shadow: var(--overlay-shadow);
    transform: translateY(calc(100% + 24px));
    transition: transform 160ms ease;
    pointer-events: none;
  }

  .history-tools .segmented {
    max-width: 100%;
    overflow-x: auto;
  }

  .history-tools .segmented button {
    white-space: nowrap;
  }

  .app-shell.chat-tools-open .history-tools {
    transform: translateY(0);
    pointer-events: auto;
  }

  .message-actions {
    justify-content: stretch;
  }

  .message-actions button {
    flex: 1 1 calc(50% - 4px);
    padding: 0 8px;
  }

  .history-search {
    grid-template-columns: 1fr auto auto;
  }

  .messages {
    padding: 12px 10px;
  }

  .chat-drop-overlay {
    inset: 58px 0 0;
    padding: 12px;
  }

  .chat-drop-card {
    width: min(280px, 100%);
    padding: 14px;
  }

  .user-detail-backdrop {
    justify-content: stretch;
    background: var(--surface);
  }

  .user-detail-panel {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }

  .user-detail-body {
    padding: 18px 16px max(20px, env(safe-area-inset-bottom));
  }

  .user-detail-avatar {
    width: 88px;
    height: 88px;
    min-height: 88px;
    border-radius: 18px;
  }

  .user-detail-heading h3 {
    font-size: 20px;
  }

  .message {
    max-width: 96%;
    gap: 6px;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    margin-top: 18px;
  }

  .message-toolbar {
    display: none;
  }

  .attachment-failure {
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
    width: 100%;
    max-width: 100%;
  }

  .attachment-failure-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .composer {
    gap: 6px;
    padding: 8px;
  }

  .composer-tools {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  .composer-tools .icon-button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
  }

  .composer-input-row {
    grid-template-columns: minmax(0, 1fr) minmax(64px, auto);
    gap: 6px;
  }

  .emoji-panel {
    max-height: min(312px, 46dvh);
    padding: 7px;
  }

  .emoji-panel-tabs button {
    min-height: 30px;
    padding: 0 9px;
  }

  .emoji-grid,
  .sticker-grid {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  }

  .emoji-page-grid {
    grid-template-columns: repeat(8, minmax(36px, 40px));
    grid-auto-rows: minmax(36px, 40px);
  }

  .emoji-page-viewport {
    min-height: 156px;
  }

  .composer textarea {
    max-height: 88px;
    min-height: 40px;
    padding: 8px 9px;
  }

  .composer button[type="submit"] {
    min-height: 40px;
    padding: 0 8px;
    width: 100%;
  }

  .icon-button {
    min-height: 40px;
  }

  .voice-recorder {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }

  .voice-recorder .ghost-button {
    flex: 1 1 112px;
    padding: 0 8px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .image-preview-backdrop {
    align-items: stretch;
    padding: 0;
  }

  .message-action-dialog {
    width: 100%;
    max-height: min(70dvh, 520px);
    border-radius: var(--overlay-radius) var(--overlay-radius) 0 0;
  }

  .image-preview-actions {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    gap: 8px;
  }

  .image-preview-action-button,
  .image-preview-action-link {
    width: 48px;
    height: 48px;
    min-height: 48px;
    font-size: 22px;
  }

  #imagePreviewZoomOutBtn,
  #imagePreviewResetBtn,
  #imagePreviewZoomInBtn {
    display: none;
  }

  .image-preview-info {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    max-width: calc(100vw - 20px);
  }

  .paste-dialog {
    max-height: min(76dvh, 560px);
    padding: 14px;
  }

  .paste-preview img {
    max-height: 260px;
  }

  .mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 30;
    width: min(300px, 82vw);
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: 48px;
    align-content: start;
    gap: 8px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
    padding: calc(env(safe-area-inset-top) + 18px) 14px 14px;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    pointer-events: none;
  }

  .app-shell.mobile-menu-open .mobile-nav {
    transform: translateX(0);
    pointer-events: auto;
  }

  .mobile-nav button {
    min-height: 44px;
    background: var(--surface-strong);
    color: var(--text);
    position: relative;
    text-align: left;
  }

  .mobile-nav button.active {
    background: var(--active-bg);
    color: var(--active-text);
    border-color: var(--active-border);
  }

  .mobile-nav-close {
    background: transparent;
    color: var(--muted);
    justify-self: end;
    min-height: 36px;
  }

  .mobile-nav button.has-unread::after {
    content: attr(data-unread);
    position: absolute;
    top: 4px;
    right: 16px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    padding: 0 5px;
  }

  .admin-sidebar {
    padding: 18px;
    position: static;
    min-height: auto;
    max-height: none;
    overflow: visible;
    grid-template-rows: auto auto auto auto;
    gap: 12px;
  }

  .admin-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .admin-nav a {
    flex: 0 0 auto;
    min-height: 34px;
    white-space: nowrap;
  }

  .admin-content {
    padding: 16px;
  }

  .admin-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-message-actions {
    justify-content: flex-start;
  }

  .admin-message-filter {
    grid-template-columns: 1fr;
  }

  .admin-message-filter button[type="submit"] {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody {
    display: grid;
    gap: 10px;
  }

  .admin-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 10px;
  }

  .admin-table td {
    display: grid;
    grid-template-columns: minmax(76px, 0.36fr) minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    border-bottom: 0;
    padding: 7px 0;
    overflow-wrap: anywhere;
  }

  .admin-table td::before {
    content: attr(data-label);
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    line-height: 1.35;
  }

  .admin-table td[colspan] {
    grid-template-columns: 1fr;
    color: var(--muted);
    text-align: left;
  }

  .admin-table td[colspan]::before {
    display: none;
  }

  .admin-table td input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  .admin-log-table {
    table-layout: auto;
  }

  .admin-log-table th:first-child,
  .admin-log-time-cell {
    width: auto;
  }

  .admin-user-actions,
  .reset-password-form {
    width: 100%;
    min-width: 0;
  }

  .reset-password-form {
    grid-template-columns: 1fr;
  }

  .admin-user-actions > .ghost-button {
    width: 100%;
  }

  .admin-confirm-dialog {
    width: min(328px, calc(100vw - 24px));
  }

  .admin-confirm-panel {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .admin-confirm-icon {
    width: 32px;
    height: 32px;
  }

  .admin-confirm-actions {
    justify-content: stretch;
  }

  .admin-confirm-actions .ghost-button {
    flex: 1 1 0;
    min-width: 0;
  }

  .profile-page {
    padding: 16px;
  }

  .profile-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .reset-password-form {
    min-width: 190px;
  }

  .admin-user-actions {
    min-width: 190px;
  }
}
