:root {
  color-scheme: light;
  --app-height: 100dvh;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --bar: rgba(249, 249, 251, 0.86);
  --line: #d8d8df;
  --line-strong: #c7c7cc;
  --text: #111827;
  --muted: #6b7280;
  --accent: #007aff;
  --accent-dark: #0062cc;
  --danger: #b42318;
  --mine: #007aff;
  --theirs: #ffffff;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 650;
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  height: var(--app-height);
  max-height: var(--app-height);
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

.auth-view {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f5fbfa 100%);
}

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

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

.brand-row h1 {
  font-size: 21px;
  line-height: 1.2;
}

.brand-row p,
.topbar p,
.chat-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
}

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

input {
  min-height: 44px;
  padding: 0 12px;
}

select {
  min-height: 40px;
  padding: 0 34px 0 10px;
}

textarea {
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.16);
}

.error-text {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.chat-view {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.app-notice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff7ed;
  color: #8a4b12;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.app-notice button {
  width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(138, 75, 18, 0.1);
  color: #8a4b12;
  font-size: 18px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bar);
  backdrop-filter: blur(16px);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-height: 112px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bar);
  backdrop-filter: blur(16px);
}

.chat-header {
  justify-content: space-between;
}

.chat-header > div {
  min-width: 0;
  flex: 1;
}

.message-search {
  width: min(240px, 34vw);
  min-height: 38px;
}

.remote-search-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-actions::-webkit-scrollbar {
  display: none;
}

.toolbar-actions select {
  flex: 1 1 82px;
  min-width: 76px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 650;
}

.toolbar-actions .icon-button {
  flex: 0 0 34px;
  width: 34px;
  min-height: 34px;
  font-size: 17px;
}

.topbar h1,
.chat-header h2 {
  font-size: 18px;
  line-height: 1.2;
}

.topbar h1 {
  font-size: 28px;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid rgba(199, 199, 204, 0.72);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 20px;
  backdrop-filter: blur(12px);
}

.dialog-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.empty-note {
  padding: 20px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.search-box input {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: #eef0f4;
}

.search-box button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
  border-radius: 12px;
}

.dialog-filters {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.dialog-filters button {
  min-height: 32px;
  flex: 1;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #eef0f4;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.dialog-filters button.active {
  background: var(--accent);
  color: #fff;
}

.dialog-button {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 5px 11px;
  width: 100%;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.dialog-button:hover,
.dialog-button.active {
  border-color: transparent;
  background: #eef4ff;
}

.dialog-title,
.dialog-preview,
.dialog-date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-title {
  grid-column: 2;
  font-size: 15px;
  font-weight: 720;
}

.dialog-avatar {
  grid-row: 1 / 3;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, hsl(var(--avatar-hue, 205) 78% 58%), hsl(calc(var(--avatar-hue, 205) + 34) 78% 45%));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12);
}

.dialog-button.muted .dialog-title {
  color: #4b5563;
}

.dialog-preview {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.dialog-date {
  grid-column: 3;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.dialog-pin {
  display: inline-grid;
  min-width: 32px;
  height: 18px;
  place-items: center;
  margin-right: 6px;
  border-radius: 999px;
  background: #e8f1ff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  vertical-align: 1px;
}

.global-result .dialog-preview mark {
  border-radius: 4px;
  padding: 0 2px;
  background: #fff3a3;
  color: inherit;
}

.unread {
  grid-column: 3;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.dialog-muted,
.muted-unread {
  grid-column: 3;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border-radius: 999px;
  padding: 0 6px;
  border: 1px solid var(--line);
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.conversation {
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
  background:
    radial-gradient(circle at 10% 12%, rgba(0, 122, 255, 0.035), transparent 26%),
    linear-gradient(180deg, #f5f6fa 0%, #ffffff 58%);
}

.date-divider {
  display: table;
  margin: 12px auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(142, 142, 147, 0.16);
  color: #6b7280;
  font-size: 12px;
  font-weight: 720;
}

.load-more {
  display: block;
  width: fit-content;
  min-height: 34px;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.message-list.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.message {
  display: grid;
  justify-items: start;
  margin: 7px 0;
}

.message.mine {
  justify-items: end;
}

.bubble {
  max-width: min(640px, 82%);
  border-radius: 18px;
  padding: 8px 10px 6px 12px;
  background: var(--theirs);
  color: var(--text);
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

.sender-name {
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
}

.message-text {
  vertical-align: baseline;
}

.bubble-time {
  display: inline-block;
  margin-left: 8px;
  color: rgba(107, 114, 128, 0.82);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  vertical-align: baseline;
}

.bubble mark {
  border-radius: 4px;
  padding: 0 2px;
  background: #fff3a3;
  color: inherit;
}

.media-preview {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  margin-bottom: 8px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid rgba(16, 32, 29, 0.08);
  cursor: zoom-in;
}

.file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.message.mine .bubble {
  background: var(--mine);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.message.mine .bubble-time {
  color: rgba(255, 255, 255, 0.78);
}

.message:not(.mine) .bubble {
  border-bottom-left-radius: 5px;
  border: 1px solid rgba(216, 216, 223, 0.75);
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bar);
  backdrop-filter: blur(16px);
}

.composer button {
  min-width: 44px;
}

.composer .icon-button {
  min-width: 44px;
}

.composer textarea {
  border: 1px solid #d1d1d6;
  border-radius: 20px;
  min-height: 42px;
  padding: 10px 13px;
  background: #fff;
}

.send-button {
  display: grid;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
  background: var(--accent);
}

.jump-bottom {
  position: absolute;
  right: 14px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  width: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(199, 199, 204, 0.74);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent);
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.16);
  backdrop-filter: blur(14px);
  font-size: 20px;
}

.jump-bottom.has-news {
  width: auto;
  min-width: 112px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 760;
}

.file-input {
  display: none;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.danger-button {
  border: 1px solid #f3b8b2;
  background: #fff4f2;
  color: var(--danger);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 32, 29, 0.28);
}

.modal-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-panel h2 {
  font-size: 18px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

.status-panel {
  gap: 16px;
}

.new-chat-result {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.new-chat-result .dialog-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.update-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-grid {
  display: grid;
  gap: 8px;
}

.users-panel {
  width: min(520px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  overflow: auto;
}

.current-user {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f2f2f7;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.compact-form {
  gap: 10px;
  margin-top: 0;
}

.admin-users {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.admin-users h3 {
  margin: 0;
  font-size: 15px;
}

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

.audit-list {
  display: grid;
  gap: 7px;
  max-height: 180px;
  overflow: auto;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

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

.user-actions button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.user-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.user-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.audit-row {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.audit-row strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.audit-row span {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.status-item {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  font-size: 13px;
  line-height: 1.35;
}

.status-label {
  color: var(--muted);
  font-weight: 700;
}

.status-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-only {
  display: none;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 14, 12, 0.86);
}

.image-modal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.image-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 21;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
}

.action-sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  padding: 12px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.18);
}

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

.action-sheet button {
  min-height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent);
  box-shadow: 0 1px 0 rgba(60, 60, 67, 0.12);
  backdrop-filter: blur(18px);
  font-size: 17px;
  font-weight: 650;
}

.action-sheet .action-cancel {
  margin-top: 2px;
  color: #111827;
  font-weight: 760;
}

@media (max-width: 760px) {
  body {
    overscroll-behavior: none;
    background: var(--surface);
  }

  .chat-view {
    grid-template-columns: 1fr;
    height: var(--app-height);
    max-height: var(--app-height);
    background: var(--surface);
  }

  .sidebar,
  .conversation {
    grid-column: 1;
    grid-row: 1;
  }

  .conversation {
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    background: #fff;
    box-shadow: -18px 0 38px rgba(17, 24, 39, 0.12);
  }

  .chat-view.conversation-open .conversation {
    transform: translateX(0);
  }

  .chat-view.conversation-open .sidebar {
    visibility: hidden;
  }

  .mobile-only {
    display: grid;
  }

  .message-list {
    padding: 12px 10px 14px;
    -webkit-overflow-scrolling: touch;
  }

  .bubble {
    max-width: 80%;
    font-size: 15px;
    line-height: 1.36;
  }

  .chat-header {
    position: relative;
    top: auto;
    z-index: 2;
    min-height: 58px;
    align-items: center;
    flex-wrap: nowrap;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    border-bottom-color: rgba(216, 216, 223, 0.72);
    background: rgba(249, 249, 251, 0.86);
    backdrop-filter: blur(18px);
  }

  .chat-header h2 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .message-search {
    display: none;
    position: absolute;
    left: 10px;
    right: 96px;
    bottom: -46px;
    width: auto;
    min-height: 40px;
    z-index: 3;
  }

  .remote-search-button {
    display: none;
    position: absolute;
    right: 10px;
    bottom: -46px;
    min-width: 82px;
    z-index: 3;
  }

  .chat-view.search-open .chat-header {
    margin-bottom: 48px;
  }

  .chat-view.search-open .message-search,
  .chat-view.search-open .remote-search-button {
    display: block;
  }

  .toolbar-actions {
    gap: 6px;
  }

  .topbar {
    position: relative;
    top: auto;
    z-index: 2;
    min-height: 122px;
    padding: calc(12px + env(safe-area-inset-top)) 12px 10px;
    background: rgba(249, 249, 251, 0.9);
  }

  .topbar h1 {
    font-size: 31px;
  }

  .topbar p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-box {
    position: relative;
    top: auto;
    z-index: 1;
    padding: 8px 10px;
    background: rgba(249, 249, 251, 0.94);
    backdrop-filter: blur(18px);
  }

  .status-item {
    grid-template-columns: 92px 1fr;
  }

  .icon-button {
    width: 38px;
    min-height: 38px;
  }

  .dialog-list {
    padding: 0 0 10px;
  }

  .dialog-button {
    min-height: 74px;
    padding: 9px 12px;
    border-radius: 0;
    border-color: transparent;
    border-bottom-color: var(--line);
  }

  .dialog-button:hover,
  .dialog-button.active {
    border-color: transparent;
    border-bottom-color: var(--line);
    background: #edf5ff;
  }

  .dialog-title {
    font-size: 15px;
  }

  .dialog-preview {
    font-size: 13px;
  }

  .composer {
    gap: 7px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top-color: rgba(216, 216, 223, 0.7);
  }

  .composer .icon-button,
  .composer .send-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .composer textarea {
    min-height: 42px;
    max-height: 104px;
  }
}

@media (max-width: 760px) {
  :root {
    --bg: #f2f2f7;
    --surface: #f9f9fb;
    --line: rgba(60, 60, 67, 0.18);
    --text: #111827;
    --muted: #7b8494;
  }

  .app-shell,
  .chat-view,
  .sidebar,
  .conversation {
    height: 100dvh;
    height: var(--app-height);
    max-height: var(--app-height);
  }

  .sidebar {
    grid-template-rows: auto auto auto auto 1fr;
    border-right: 0;
    background: #f2f2f7;
  }

  .app-notice {
    margin: 8px 10px 0;
    border: 0;
    border-radius: 13px;
    background: #fff4df;
    box-shadow: 0 1px 0 rgba(60, 60, 67, 0.08);
  }

  .topbar {
    min-height: auto;
    padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
    border-bottom: 0;
    background: rgba(242, 242, 247, 0.92);
  }

  .topbar > div:first-child {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 34px;
    line-height: 1.05;
    font-weight: 820;
  }

  .topbar p {
    justify-self: end;
    max-width: 138px;
    margin-bottom: 2px;
    color: #34c759;
    font-size: 12px;
    font-weight: 720;
    text-align: right;
  }

  .toolbar-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .toolbar-actions::-webkit-scrollbar {
    display: none;
  }

  .toolbar-actions select {
    width: auto;
    min-width: 118px;
    height: 36px;
    min-height: 36px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(60, 60, 67, 0.12);
    color: var(--accent);
    font-size: 14px;
  }

  .toolbar-actions .icon-button {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    min-height: 36px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 0 rgba(60, 60, 67, 0.12);
    color: var(--accent);
    font-size: 19px;
  }

  .toolbar-actions #addAccount,
  .toolbar-actions #manageAccount,
  .toolbar-actions #notifyButton,
  .toolbar-actions #statusButton,
  .toolbar-actions #usersButton,
  .toolbar-actions #lockButton {
    display: none;
  }

  .toolbar-actions #refreshDialogs,
  .toolbar-actions #mobileMoreActions {
    display: grid;
  }

  .search-box {
    top: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 0;
    background: rgba(242, 242, 247, 0.94);
  }

  .search-box input {
    min-height: 38px;
    border-radius: 11px;
    background: #e5e5ea;
    color: #111827;
    font-size: 16px;
  }

  .search-box input::placeholder {
    color: #8e8e93;
  }

  .search-box button {
    min-width: 70px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--accent);
    font-size: 15px;
    font-weight: 720;
  }

  .dialog-filters {
    gap: 0;
    margin: 0 12px 8px;
    padding: 2px;
    border: 0;
    border-radius: 10px;
    background: #e5e5ea;
  }

  .dialog-filters button {
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4b5563;
    font-size: 13px;
    transition: background 160ms ease, color 160ms ease;
  }

  .dialog-filters button.active {
    background: #fff;
    color: #111827;
    box-shadow: 0 1px 3px rgba(60, 60, 67, 0.18);
  }

  .dialog-list {
    margin: 0 10px 10px;
    padding: 0;
    border-radius: 18px;
    background: #fff;
    overflow: auto;
  }

  .dialog-button {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    min-height: 76px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid rgba(60, 60, 67, 0.13);
    background: #fff;
  }

  .dialog-button:last-child {
    border-bottom: 0;
  }

  .dialog-button:hover,
  .dialog-button.active {
    background: #f1f7ff;
    border-bottom-color: rgba(60, 60, 67, 0.13);
  }

  .dialog-avatar {
    width: 50px;
    height: 50px;
    font-size: 19px;
  }

  .dialog-title {
    font-size: 16px;
    font-weight: 760;
  }

  .dialog-preview {
    grid-column: 2 / -1;
    font-size: 14px;
    color: #7b8494;
  }

  .dialog-date {
    align-self: start;
    padding-top: 2px;
    font-size: 12px;
  }

  .unread,
  .dialog-muted,
  .muted-unread {
    align-self: start;
    margin-top: 1px;
  }

  .conversation {
    grid-template-rows: auto 1fr auto;
    background: #f2f2f7;
    box-shadow: -16px 0 42px rgba(17, 24, 39, 0.18);
  }

  .chat-header {
    min-height: 60px;
    padding: calc(7px + env(safe-area-inset-top)) 10px 7px;
    border-bottom: 1px solid rgba(60, 60, 67, 0.16);
    background: rgba(249, 249, 251, 0.88);
  }

  #backToDialogs {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 34px;
    box-shadow: none;
  }

  #toggleMessageSearch {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 0 rgba(60, 60, 67, 0.12);
  }

  .chat-header h2 {
    font-size: 17px;
    font-weight: 780;
    text-align: center;
  }

  .chat-header p {
    margin-top: 2px;
    color: #8e8e93;
    font-size: 12px;
    text-align: center;
  }

  .message-search {
    left: 12px;
    right: 98px;
    bottom: -48px;
    border: 0;
    border-radius: 12px;
    background: #e5e5ea;
  }

  .remote-search-button {
    right: 12px;
    bottom: -48px;
    border: 0;
    color: var(--accent);
  }

  .message-list {
    padding: 12px 10px 14px;
    background:
      radial-gradient(circle at 18% 18%, rgba(0, 122, 255, 0.05), transparent 28%),
      linear-gradient(180deg, #f7f7fb 0%, #fff 72%);
  }

  .date-divider {
    background: rgba(142, 142, 147, 0.18);
    color: #6b7280;
  }

  .bubble {
    max-width: 82%;
    border-radius: 19px;
    padding: 8px 10px 6px 12px;
    font-size: 16px;
    line-height: 1.34;
  }

  .message:not(.mine) .bubble {
    border: 0;
    background: #fff;
  }

  .message.mine .bubble {
    background: var(--accent);
  }

  .composer {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(60, 60, 67, 0.16);
    background: rgba(249, 249, 251, 0.9);
  }

  .composer textarea {
    min-height: 42px;
    border: 1px solid #d1d1d6;
    border-radius: 21px;
    font-size: 16px;
  }

  .composer .icon-button,
  .composer .send-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border: 0;
    box-shadow: none;
  }

  .composer .icon-button {
    background: transparent;
    color: var(--accent);
    font-size: 27px;
  }

  .composer .send-button {
    background: var(--accent);
    color: #fff;
    font-size: 18px;
  }
}
