:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #dce6ef;
  --ink: #111827;
  --muted: #7c8794;
  --line: #d9e0e7;
  --panel: #ffffff;
  --accent: #229ed9;
  --accent-dark: #168ac2;
  --bubble: #effdde;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { overscroll-behavior: none; }
button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.shell { min-height: 100svh; display: grid; }
.hidden { display: none !important; }

.auth {
  width: min(100%, 430px);
  margin: auto;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
.brand-mark {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 -8px 14px rgba(0, 0, 0, .12);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .11);
}

.panel h2 { margin: 0 0 18px; font-size: 20px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px 15px;
  background: #f4f7fa;
  color: var(--ink);
  outline: none;
}
textarea {
  min-height: 84px;
  resize: vertical;
  border-radius: 14px;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 158, 217, .13); background: #fff; }

button {
  min-height: 44px;
  border-radius: 22px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  font-weight: 700;
}
.ghost { width: 100%; margin-top: 10px; color: var(--accent); background: #e8f5fc; }
.error { min-height: 20px; color: var(--danger); margin: 12px 0 0; font-size: 14px; }
.readonly-id {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 8px;
  background: #f4f7fa;
  color: var(--muted);
  font-size: 14px;
}

.photo-picker { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.photo-preview-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.photo-picker img {
  position: relative;
  z-index: 1;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.photo-loader {
  position: absolute;
  z-index: 0;
  inset: -4px;
  display: none;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0 22%, var(--accent) 22% 48%, #22c55e 48% 68%, transparent 68% 100%);
  filter: drop-shadow(0 4px 12px rgba(34, 158, 217, .26));
  animation: photo-loader-spin .9s linear infinite;
}

.photo-loader::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}

.photo-picker.loading .photo-loader {
  display: block;
}

.photo-picker.loading img {
  opacity: .58;
}

.file-control {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.file-control input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-button {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  border-radius: 20px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.file-button:hover,
.file-control input[type="file"]:focus-visible + .file-button {
  background: var(--accent-dark);
  box-shadow: 0 0 0 3px rgba(34, 158, 217, .16);
}

.file-control small {
  max-width: 230px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes photo-loader-spin {
  to { transform: rotate(1turn); }
}

.app {
  width: min(100%, 1180px);
  height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .08);
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100svh;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  transition: transform .24s ease, opacity .18s ease;
}

.side-head, .chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: #fff;
}

.profile-entry {
  flex: 0 0 auto;
}

.avatar-button {
  position: relative;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
}

.me-badge {
  position: absolute;
  right: -3px;
  bottom: -2px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.avatar-button img, .avatar-inline img, .peer-photo-button img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.avatar-inline, .peer-photo-button {
  position: relative;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
}

.peer-photo-button {
  flex: 0 0 auto;
}

.status-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #cbd5e1;
}

.status-dot.online {
  background: #22c55e;
}

.side-title, .peer-title { min-width: 0; flex: 1; }
.side-title strong, .side-title span, .chat-head strong, .chat-head span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-title span, .chat-head span { color: var(--muted); font-size: 13px; }

.icon, .back {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--muted);
  background: #f1f5f9;
}

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

.chat-actions .icon,
.icon-action {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.chat-actions .icon:hover,
.icon-action:hover {
  background: var(--accent-dark);
}

.chat-actions .destructive-icon {
  background: var(--danger);
}

.chat-actions .destructive-icon:hover {
  background: #b91c1c;
}

.danger-action { color: #fff; }

.chat-actions .icon svg,
.icon-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-wrap {
  padding: 0 12px 10px;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 42px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.1;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}

.bottom-nav button span {
  display: block;
  font-size: 17px;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--accent);
  background: #e8f5fc;
}

.bottom-nav button:active {
  transform: scale(.96);
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.chat-row {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 70px;
  padding: 8px 12px;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 400;
  cursor: pointer;
}

.chat-row:hover, .chat-row.active { background: #e8f5fc; }
.chat-main { min-width: 0; display: grid; gap: 4px; }
.chat-main strong, .chat-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-main small, .chat-time, .empty-list { color: var(--muted); font-size: 13px; }
.chat-side {
  align-self: stretch;
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 7px;
  padding-top: 8px;
}
.friend-action {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  font-size: 12px;
}

.friend-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.approved-check {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #22c55e;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.danger-text {
  color: var(--danger);
  background: #fee2e2;
}

.unread {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}
.empty-list { padding: 28px 16px; text-align: center; }

.list-count {
  padding: 18px 16px 22px;
  color: #8a96a3;
  font-size: 13px;
  text-align: center;
}

.contact-filters {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px 9px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.contact-filters::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.contact-filters button,
.list-filters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--muted);
  background: #f1f5f9;
  white-space: nowrap;
}

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

.contact-filters button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 800;
}

.list-filters {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px 10px;
  overflow: visible;
}

.list-filters button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 15px;
  font-size: 12px;
}

.filter-badge {
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

button.active .filter-badge {
  color: #fff;
  background: rgba(255, 255, 255, .28);
}

.contact-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 5px 10px;
  color: var(--ink);
  cursor: pointer;
}

.contact-row:hover, .contact-row.active { background: #e8f5fc; }
.contact-main {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.contact-main strong, .contact-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-main strong {
  font-size: 14px;
  font-weight: 700;
}

.contact-main small {
  color: var(--muted);
  font-size: 12px;
}

.contact-main .online-text {
  color: #16a34a;
  font-weight: 700;
}

.avatar-inline.compact-avatar,
.avatar-inline.compact-avatar img {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

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

.group-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 32px;
  overflow: hidden;
}

.group-menu-button {
  font-size: 18px;
  letter-spacing: 0;
  transform: scale(1);
  opacity: 1;
  transition: width .18s ease, min-width .18s ease, transform .18s ease, opacity .18s ease;
}

.group-actions.open .group-menu-button {
  width: 0;
  min-width: 0;
  transform: scale(.5) rotate(90deg);
  opacity: 0;
  pointer-events: none;
}

.group-actions-menu {
  display: flex;
  gap: 6px;
  max-width: 0;
  transform: translateX(10px) scale(.84);
  opacity: 0;
  pointer-events: none;
  transition: max-width .22s ease, transform .22s ease, opacity .16s ease;
}

.group-actions.open .group-actions-menu {
  max-width: 76px;
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.icon-action.danger-icon {
  background: var(--danger);
}

.icon-action.danger-icon:hover {
  background: #b91c1c;
}

.mini-action {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 14px;
  font-size: 12px;
}

.muted-action {
  color: var(--muted);
  background: #f1f5f9;
}

.create-group {
  width: calc(100% - 20px);
  min-height: 38px;
  margin: 4px 10px 8px;
  border-radius: 8px;
  color: var(--accent);
  background: #e8f5fc;
  text-align: left;
}

.group-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #229ed9, #22c55e);
  font-size: 15px;
  font-weight: 800;
}

.group-head-avatar, .group-info-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #229ed9, #22c55e);
  font-size: 15px;
  font-weight: 800;
}

.peer-title button {
  width: 100%;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.chat {
  min-width: 0;
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    linear-gradient(rgba(220, 230, 239, .86), rgba(220, 230, 239, .86)),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .75), transparent 24%),
    radial-gradient(circle at 80% 40%, rgba(255, 255, 255, .55), transparent 28%);
}

.chat-head {
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .75);
}

.back {
  display: none;
  font-size: 32px;
  line-height: 1;
  font-weight: 400;
  color: var(--accent);
  background: transparent;
}

.empty-chat {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 7px;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}
.empty-chat strong { color: #4b5563; }

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 18px;
}

.friend-gate {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 18px calc(env(safe-area-inset-bottom) + 14px);
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid rgba(15, 23, 42, .08);
  text-align: center;
}

.friend-gate strong {
  color: #334155;
  font-size: 15px;
}

.friend-gate span {
  max-width: 520px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.friend-gate button {
  min-height: 38px;
  border-radius: 19px;
}

.settings-view {
  height: 100svh;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.settings-head {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  max-width: 780px;
  margin: 0 auto 14px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.settings-head img {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.settings-head span,
.settings-menu button span:last-child,
.device-row span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.settings-head strong,
.settings-menu strong,
.device-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-head small,
.settings-menu small,
.device-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-head button {
  min-height: 36px;
  border-radius: 18px;
}

.settings-layout {
  max-width: 780px;
  min-height: calc(100svh - 132px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.settings-menu {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.settings-menu button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.settings-menu button.active,
.settings-menu button:hover {
  background: #e8f5fc;
}

.settings-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 17px;
  line-height: 1;
}

.settings-card {
  max-height: calc(100svh - 152px);
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.settings-card h3 {
  margin: 0;
  font-size: 18px;
}

.settings-card p {
  margin: 0;
  color: #475569;
  line-height: 1.45;
}

.profile-summary {
  justify-items: center;
  text-align: center;
}

.profile-summary img {
  width: min(42vw, 150px);
  height: min(42vw, 150px);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.profile-summary span {
  color: var(--muted);
  font-size: 14px;
}

.settings-rows {
  min-height: 0;
  max-height: calc(100svh - 224px);
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding-right: 2px;
  scrollbar-width: thin;
}

.device-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.settings-mini-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.mini-danger {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 16px;
  color: var(--danger);
  background: #fee2e2;
  font-size: 12px;
}

.privacy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
}

.privacy-grid span {
  color: var(--muted);
}

.privacy-controls {
  display: grid;
  gap: 8px;
}

.privacy-option {
  grid-template-columns: minmax(0, 1fr) minmax(130px, auto);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: #f8fafc;
}

.privacy-option select {
  width: auto;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.settings-note {
  color: var(--muted) !important;
  font-size: 13px;
}

.language-switch {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #eef2f7;
}

.language-switch button {
  min-height: 40px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.language-switch button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.language-flag {
  width: 34px;
  height: 23px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .16), 0 1px 2px rgba(15, 23, 42, .12);
}

.language-flag-text {
  color: #0f172a;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

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

.news-list span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.news-list small {
  color: var(--muted);
  line-height: 1.35;
}

.chat-list, .messages {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-list::-webkit-scrollbar, .messages::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.day {
  width: fit-content;
  margin: 12px auto;
  padding: 5px 10px;
  border-radius: 14px;
  color: #64748b;
  background: rgba(255, 255, 255, .7);
  font-size: 12px;
}

.unread-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.unread-separator::before,
.unread-separator::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(34, 158, 217, .35);
  box-shadow: 0 1px 8px rgba(34, 158, 217, .18);
}

.unread-separator span {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 3px 14px rgba(34, 158, 217, .13);
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 7px 0;
}
.message.own { justify-content: flex-end; }
.message.selected .bubble { outline: 2px solid rgba(34, 158, 217, .45); }

.message-avatar {
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
}

.message-avatar img {
  width: 32px;
  height: 32px;
  display: block;
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: 50%;
  object-fit: cover;
}

.message-author {
  width: auto;
  min-height: 0;
  display: block;
  margin: 0 0 3px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border-radius: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-align: left;
}

.own .message-author {
  margin-left: auto;
  color: #2f7d32;
  text-align: right;
}

.message-check {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.message-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.bubble {
  position: relative;
  width: fit-content;
  max-width: min(78%, 520px);
  min-height: unset;
  padding: 6px 10px 5px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
  word-wrap: break-word;
  white-space: normal;
  line-height: 1.28;
}

.body {
  display: block;
  white-space: pre-wrap;
}

.own .bubble {
  background: var(--bubble);
}

.msg-time {
  position: static;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  color: #7b8794;
  font-size: 11px;
  line-height: 1;
}

.ticks {
  color: #94a3b8;
  letter-spacing: -2px;
  margin-left: 3px;
  font-weight: 700;
}
.ticks.read { color: var(--accent); }

.composer {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 8px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid rgba(15, 23, 42, .08);
}

.composer input {
  min-width: 0;
  min-height: 46px;
  background: #fff;
}
.composer button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
}

.emoji-toggle {
  color: #5f6b7a;
  background: #eef2f7 !important;
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
}

.emoji-toggle.active {
  color: #fff;
  background: var(--accent) !important;
}

.emoji-panel {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(100% + 8px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: min(318px, 46svh);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, .1);
  border-radius: 8px;
  background: rgba(248, 250, 252, .98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
  backdrop-filter: blur(18px);
}

.emoji-grid {
  order: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  align-content: start;
  gap: 2px;
  padding: 10px 10px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.emoji-grid::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.emoji-grid button {
  width: 100%;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", emoji, sans-serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.emoji-grid button:hover,
.emoji-grid button:focus-visible {
  background: rgba(15, 23, 42, .08);
}

.emoji-section-heading {
  grid-column: 1 / -1;
  padding: 10px 6px 4px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.emoji-grid .emoji-region-button {
  height: 56px;
  min-height: 56px;
  display: grid;
  grid-template-rows: 24px 1fr;
  gap: 4px;
  justify-items: center;
  align-items: center;
  font-family: inherit;
  font-size: 10px;
  line-height: 1.05;
}

.emoji-region-button span {
  width: 100%;
  overflow: hidden;
  color: #4b5563;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-flag {
  width: 32px;
  height: 22px;
  display: block;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .16), 0 1px 2px rgba(15, 23, 42, .12);
}

.message-region-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  margin: 1px 2px;
  vertical-align: middle;
}

.message-region-flag .region-flag {
  width: 27px;
  height: 18px;
  flex: 0 0 auto;
}

.message-region-flag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-tabs {
  order: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 2px;
  padding: 7px 8px calc(env(safe-area-inset-bottom) + 7px);
  border-top: 1px solid rgba(15, 23, 42, .08);
  background: rgba(238, 242, 247, .98);
}

.emoji-tabs button {
  width: 100%;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  color: #6b7280;
  background: transparent;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", emoji, sans-serif;
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
}

.emoji-tabs button.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .1);
}
.send-button {
  color: #fff;
  background: #050505 !important;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

dialog {
  width: min(92vw, 420px);
  border: 0;
  padding: 0;
  background: transparent;
}
dialog::backdrop { background: rgba(17, 24, 39, .42); }
.profile-panel { box-shadow: 0 30px 70px rgba(0, 0, 0, .24); }

.profile-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #f1f5f9;
  font-size: 24px;
  line-height: 1;
}

.profile-large-photo {
  width: min(58vw, 220px);
  height: min(58vw, 220px);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.profile-card h2 {
  margin: 4px 0 0;
}

.profile-status {
  color: var(--muted);
  font-size: 14px;
}

.profile-status.online {
  color: #16a34a;
  font-weight: 700;
}

.profile-card section {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
}

.profile-card p {
  margin: 0;
  color: #475569;
  line-height: 1.4;
  white-space: pre-wrap;
}

.group-info-panel {
  position: relative;
  display: grid;
  gap: 14px;
}

.group-info-head {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

.group-info-head h2 {
  margin: 4px 0 0;
}

.group-info-head span:not(.group-info-avatar) {
  color: var(--muted);
  font-size: 13px;
}

.group-info-members {
  display: grid;
  gap: 3px;
  max-height: 320px;
  overflow: auto;
}

.group-member-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 5px 6px;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.group-member-row:hover {
  background: #f1f5f9;
}

.group-member-row span:last-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

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

.group-member-row small {
  color: var(--muted);
  font-size: 12px;
}

.group-panel {
  display: grid;
  gap: 12px;
}

.group-members {
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 4px;
}

.member-option {
  grid-template-columns: 22px 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 46px;
  margin: 0;
  padding: 5px 6px;
  border-radius: 8px;
  color: var(--ink);
}

.member-option:hover {
  background: #f1f5f9;
}

.member-option input {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.member-option img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.member-option span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.member-option strong, .member-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-option small {
  color: var(--muted);
  font-size: 12px;
}

@keyframes pulse {
  50% { transform: scale(.94); }
}

@media (max-width: 760px) {
  .app {
    width: 100%;
    position: relative;
    display: block;
    overflow: hidden;
  }
  .sidebar, .chat {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100svh;
    min-height: 0;
    transition: transform .24s ease, opacity .18s ease;
  }
  .sidebar {
    transform: translateX(0);
    opacity: 1;
  }
  .chat {
    display: grid;
    transform: translateX(100%);
    opacity: .98;
    pointer-events: none;
  }
  .chat-open .sidebar {
    transform: translateX(-18%);
    opacity: 0;
    pointer-events: none;
  }
  .chat-open .chat {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }
  .bottom-nav {
    box-shadow: 0 -8px 22px rgba(15, 23, 42, .08);
  }
  .back { display: grid; place-items: center; }
  .messages { padding: 14px 10px 14px; }
  .bubble { max-width: 86%; }
  .composer {
    width: 100vw;
    max-width: 100vw;
    grid-template-columns: 46px minmax(0, calc(100vw - 128px)) 46px;
    padding-left: 10px;
    padding-right: 10px;
  }
  .emoji-panel {
    left: 8px;
    right: 8px;
    height: min(328px, 52svh);
  }
  .emoji-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  .settings-view {
    height: 100svh;
    padding: 12px;
  }
  .settings-head {
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 10px;
  }
  .settings-head img {
    width: 54px;
    height: 54px;
  }
  .settings-layout {
    min-height: auto;
    grid-template-columns: 1fr;
  }
  .settings-menu {
    gap: 1px;
  }
  .settings-detail {
    min-width: 0;
  }
  .settings-card {
    max-height: none;
  }
  .settings-rows {
    max-height: none;
    overflow: visible;
  }
  .device-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }
  .device-row button {
    grid-column: 2;
    justify-self: start;
  }
  .privacy-grid {
    grid-template-columns: 1fr;
  }
  .privacy-option {
    grid-template-columns: 1fr;
  }
  .privacy-option select {
    width: 100%;
  }
}
