:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: #0b1018;
  --panel-2: #111a25;
  --panel-3: #172331;
  --text: #f4f7fb;
  --muted: #91a0b3;
  --line: rgba(255, 255, 255, 0.1);
  --gold: #d6b15f;
  --cyan: #5fd2ff;
  --green: #32d583;
  --danger: #ff5d5d;
  --radius-sm: 18px;
  --radius-md: 24px;
  --radius-lg: 32px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-right: env(safe-area-inset-right, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-left: env(safe-area-inset-left, 0px);
  --app-header-base-height: 68px;
  --app-header-height: calc(var(--app-header-base-height) + var(--app-safe-top));
  --app-bottom-nav-base-height: 68px;
  --app-bottom-nav-height: calc(var(--app-bottom-nav-base-height) + var(--app-safe-bottom));
  --profile-header-base-height: 52px;
  --profile-header-height: calc(var(--profile-header-base-height) + var(--app-safe-top));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edf1f5;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --panel-3: #e9eef4;
  --text: #111927;
  --muted: #617083;
  --line: rgba(17, 25, 39, 0.12);
  --gold: #9b6b15;
  --cyan: #0077b6;
  --shadow: 0 18px 60px rgba(17, 25, 39, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body.call-open {
  background: #000;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  transform: translate3d(0, var(--viewport-offset-top, 0px), 0);
  will-change: transform;
}

.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, var(--app-safe-top)) max(18px, var(--app-safe-right)) max(18px, var(--app-safe-bottom)) max(18px, var(--app-safe-left));
  overflow: auto;
}

.auth-wrap {
  width: min(460px, 100%);
}

.download-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, var(--app-safe-top)) max(18px, var(--app-safe-right)) max(18px, var(--app-safe-bottom)) max(18px, var(--app-safe-left));
}

.download-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
}

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

.brand-mark,
.empty-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(214, 177, 95, 0.45);
  background: var(--panel-2);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-lockup h1,
.empty-chat h2 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0;
}

.brand-lockup p,
.empty-chat p,
.muted {
  color: var(--muted);
}

.error-text {
  color: var(--danger);
}

.setup-alert {
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 93, 93, 0.36);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
  color: var(--text);
}

.auth-card,
.sidebar-section {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.auth-card {
  padding: 20px;
}

.public-profile-landing {
  margin-bottom: 14px;
}

.public-profile-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.public-profile-avatar {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--gold) 72%, transparent);
  background: var(--panel-2);
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 800;
  overflow: hidden;
}

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

.public-profile-avatar.skeleton {
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 20%, transparent), transparent),
    var(--panel-2);
  background-size: 180% 100%;
  animation: mc-shimmer 1.2s ease-in-out infinite;
}

.public-profile-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
  text-align: center;
}

.public-profile-copy strong {
  overflow-wrap: anywhere;
  font-size: 1.18rem;
}

.public-profile-copy span,
.public-profile-copy p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.public-profile-copy .accent {
  color: var(--accent);
  font-weight: 800;
}

.public-profile-actions {
  display: grid;
  gap: 10px;
}

.public-profile-error {
  text-align: center;
}

@keyframes mc-shimmer {
  from {
    background-position: 180% 0;
  }
  to {
    background-position: -180% 0;
  }
}

.segmented {
  height: 42px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}

.segmented button {
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  border-radius: var(--radius-md);
}

input {
  height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 46px;
  resize: none;
  padding: 12px 14px;
}

input:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--cyan) 65%, var(--line));
}

.button {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: var(--text);
  background: var(--panel-2);
  font-weight: 700;
}

a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button.primary {
  width: 100%;
  border-color: rgba(214, 177, 95, 0.36);
  background: #d6b15f;
  color: #111927;
}

.button.secondary {
  background: var(--panel-3);
}

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

.install-cta {
  width: 100%;
  margin-top: 10px;
}

.android-download-cta {
  width: 100%;
  margin-top: 10px;
}

.small {
  font-size: 0.82rem;
  line-height: 1.5;
}

.messenger-view {
  height: var(--app-viewport-height, 100dvh);
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 380px 1fr;
  background: var(--bg);
  overflow: hidden;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, var(--cyan) 12%), var(--panel) 210px),
    var(--panel);
}

.sidebar-header {
  min-height: var(--app-header-height);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
  padding: calc(var(--app-safe-top) + 8px) calc(var(--app-safe-right) + 12px) 8px calc(var(--app-safe-left) + 12px);
  border-bottom: 0;
  position: relative;
  z-index: 5;
}

.chat-header {
  min-width: 0;
  min-height: calc(72px + var(--app-safe-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--app-safe-top) + 14px) calc(var(--app-safe-right) + 14px) 14px calc(var(--app-safe-left) + 14px);
  border-bottom: 1px solid var(--line);
}

.profile-chip {
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.sidebar-header .profile-chip .avatar {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
  border: 2px solid color-mix(in srgb, var(--gold) 62%, transparent);
  background: radial-gradient(circle at 28% 20%, color-mix(in srgb, var(--cyan) 32%, transparent), var(--panel-2) 54%);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

.top-title {
  min-width: 0;
  text-align: center;
}

.top-title strong {
  display: block;
  font-size: 1.22rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.top-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
}

.profile-chip strong,
.chat-title strong,
.chat-main strong,
.member-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip span:not(.avatar),
.chat-title span,
.chat-main small,
.member-main small,
.section-title span,
.invite-box span {
  display: block;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.82rem;
  overflow: hidden;
}

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

.avatar.avatar-fallback {
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--gold) 28%, transparent), transparent 44%),
    var(--panel-2);
}

#activeAvatar,
.message-avatar,
.profile-viewer-avatar,
.profile-member-row .avatar {
  cursor: pointer;
}

.header-actions {
  width: 46px;
  min-width: 46px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  color: var(--text);
}

.icon-button:hover {
  border-color: rgba(95, 210, 255, 0.44);
}

.sidebar-header .icon-button {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel-2) 86%, #fff 14%);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
}

.main-menu-wrap {
  position: relative;
}

.quick-menu {
  position: fixed;
  top: max(82px, calc(var(--app-safe-top) + 72px));
  left: max(12px, var(--app-safe-left));
  z-index: 40;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 120px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--panel) 94%, #fff 6%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.quick-menu-section {
  padding: 12px;
  border-radius: 24px;
  background: var(--panel-2);
}

.quick-menu .groups-section {
  display: block;
  flex: initial;
  min-height: 0;
  padding: 12px;
}

.quick-menu-actions {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.menu-row {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 18px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  text-decoration: none;
}

.menu-row:hover {
  background: var(--panel-2);
}

.menu-row.danger-row {
  color: var(--danger);
}

.quick-menu-actions .danger-row {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
}

.menu-meta {
  padding: 8px 12px 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.offline-banner {
  margin: 8px 12px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 44%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--gold) 16%, var(--panel));
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.native-android {
  --app-safe-top: var(--native-safe-top, 0px);
  --app-safe-right: var(--native-safe-right, 0px);
  --app-safe-bottom: var(--native-safe-bottom, 0px);
  --app-safe-left: var(--native-safe-left, 0px);
}

.native-android .app-shell {
  height: var(--app-viewport-height, 100vh);
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  max-height: var(--app-viewport-height, 100dvh);
}

.native-android .auth-view {
  height: 100%;
  min-height: 0;
  align-items: start;
  justify-items: center;
  padding: calc(var(--app-safe-top) + 6dvh) calc(var(--app-safe-right) + 18px) calc(var(--app-safe-bottom) + 18px) calc(var(--app-safe-left) + 18px);
}

.native-android .auth-wrap {
  width: min(460px, 100%);
  max-width: calc(100vw - var(--app-safe-left) - var(--app-safe-right) - 36px);
}

.native-android .brand-lockup {
  min-width: 0;
  overflow: hidden;
}

.native-android .brand-mark {
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.native-android .android-download-cta {
  display: none !important;
}

.native-android .messenger-view,
.native-android body.chat-open .chat-panel {
  height: 100%;
  max-height: 100%;
}

.native-android .sidebar {
  height: 100%;
}

.native-android .composer {
  padding-bottom: max(10px, var(--app-safe-bottom));
  margin-bottom: 0;
}

.native-android body.keyboard-open .composer {
  padding-bottom: 10px;
  margin-bottom: 0;
}

.native-android body.keyboard-open .messages {
  padding-bottom: 12px;
}

.native-android .unread-jump-button {
  bottom: calc(86px + var(--app-safe-bottom));
}

.icon-button.accent,
.send-button,
.call-button,
.attach-button {
  border-color: rgba(95, 210, 255, 0.34);
  color: var(--cyan);
}

.icon-button.danger {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.sidebar-section {
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
  padding: 10px 16px;
  background: transparent;
}

.profile-section {
  background: var(--panel);
}

.profile-section,
.family-section,
.members-section {
  display: none;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.stack-form label {
  margin-bottom: 0;
}

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

.section-title {
  display: grid;
  gap: 2px;
}

.section-title.inline {
  grid-template-columns: 1fr auto;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-title small {
  color: var(--muted);
}

.invite-box {
  margin-top: 10px;
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr 42px 42px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}

.invite-box strong {
  letter-spacing: 0.08em;
}

.people-section,
.contacts-section,
.groups-section {
  background: transparent;
}

.people-section .search-box {
  min-height: 40px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-2) 86%, #fff 14%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-icon {
  color: var(--muted);
  display: grid;
  place-items: center;
}

.search-icon svg {
  width: 18px;
  height: 18px;
}

.people-section .search-box input {
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.94rem;
}

.people-section .search-box input:focus {
  border-color: transparent;
}

.people-section .search-box .icon-button {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--cyan) 16%, transparent);
}

.people-section .search-box .icon-button svg {
  width: 18px;
  height: 18px;
}

.search-results {
  margin-top: 6px;
  display: grid;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-2) 72%, transparent);
}

.search-result {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 6px 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-result:hover {
  background: var(--panel-3);
}

.chat-filter-tabs {
  display: flex;
  gap: 8px;
  padding: 4px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-filter-tabs::-webkit-scrollbar {
  display: none;
}

.chat-filter-tabs button {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--panel-2) 76%, #fff 12%);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.chat-filter-tabs button.active {
  border-color: color-mix(in srgb, var(--gold) 34%, transparent);
  background: color-mix(in srgb, var(--gold) 18%, var(--panel-2));
}

.chat-filter-tabs small {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 16%, transparent);
  color: var(--muted);
  font-size: 0.7rem;
}

.group-picker {
  display: grid;
  gap: 6px;
  max-height: 150px;
  overflow: auto;
}

.group-option {
  min-height: 40px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
}

.group-option input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.list-section {
  flex: 1.3;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 8px 8px;
}

.members-section {
  flex: 1;
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.chat-list,
.member-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 2px;
}

.chat-item,
.member-item {
  width: 100%;
  min-height: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  padding: 7px 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chat-item .avatar,
.member-item .avatar,
.search-result .avatar {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--cyan) 28%, transparent), transparent 42%),
    var(--panel-2);
}

.chat-item.group-chat .avatar {
  border-color: color-mix(in srgb, var(--cyan) 48%, var(--line));
}

.group-avatar {
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--gold) 35%, transparent), transparent 44%),
    color-mix(in srgb, var(--cyan) 18%, var(--panel-2));
}

.group-avatar-icon,
.group-avatar-icon svg {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.group-badge {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  margin-left: 7px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 16%, transparent);
  color: var(--cyan);
  font-size: 0.68rem;
  vertical-align: middle;
}

.chat-item:hover,
.chat-item.active,
.member-item:hover {
  background: var(--panel-2);
}

.chat-item.active {
  box-shadow: inset 3px 0 0 var(--gold);
}

.chat-item.has-unread .chat-main strong,
.chat-item.has-unread .chat-main small {
  font-weight: 850;
}

.chat-item.has-unread .chat-main small {
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
}

.chat-main,
.member-main {
  min-width: 0;
  flex: 1;
  display: grid;
  align-content: center;
  gap: 3px;
  overflow: hidden;
}

.chat-main strong,
.member-main strong {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}

.chat-main small,
.member-main small {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.search-result .avatar {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

.search-result strong {
  font-size: 0.95rem;
}

.search-result small {
  font-size: 0.78rem;
}

.chat-side {
  width: 52px;
  flex: 0 0 52px;
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 4px;
  color: var(--muted);
  align-self: flex-start;
  padding-top: 5px;
  overflow: visible;
}

.chat-time {
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.72rem;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--cyan);
  color: #061014;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.pin-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  color: var(--gold);
  font-size: 0.74rem;
}

.empty-list {
  padding: 12px 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-link-contact-notice {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px auto 12px;
  padding: 10px 12px;
  width: min(100%, 640px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel-2) 88%, var(--cyan) 12%);
  color: var(--muted);
  font-size: 0.86rem;
}

.profile-link-contact-notice span {
  flex: 1 1 180px;
}

.profile-link-contact-notice button {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--panel) 82%, var(--cyan) 12%);
  color: var(--cyan);
  font-weight: 800;
  cursor: pointer;
}

.profile-link-contact-notice button:hover {
  color: var(--cyan);
}

.profile-link-contact-notice [data-profile-link-dismiss] {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
}

.profile-placeholder {
  margin: 10px 8px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--panel-2) 82%, #fff 8%);
  text-align: center;
}

.profile-placeholder .avatar {
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  flex-basis: 76px;
  border: 2px solid color-mix(in srgb, var(--gold) 58%, transparent);
}

.profile-placeholder strong {
  display: block;
  font-size: 1.18rem;
}

.profile-placeholder span,
.profile-placeholder p {
  color: var(--muted);
}

.profile-placeholder p {
  margin: 12px 0 0;
}

.profile-editor {
  margin: 10px 8px calc(112px + var(--app-safe-bottom));
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--panel-2) 82%, #fff 8%);
}

.profile-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.profile-editor-head .avatar {
  width: 74px;
  height: 74px;
  flex-basis: 74px;
  border: 2px solid color-mix(in srgb, var(--gold) 58%, transparent);
}

.profile-avatar-button {
  border: 2px solid color-mix(in srgb, var(--gold) 58%, transparent);
  padding: 0;
  cursor: pointer;
}

.profile-editor-head strong,
.profile-editor-head span {
  display: block;
}

.profile-editor-head strong {
  font-size: 1.18rem;
}

.profile-editor-head span {
  color: var(--muted);
}

.profile-editor label {
  margin-bottom: 0;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

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

.profile-screen {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 10px 10px calc(96px + var(--app-safe-bottom));
  color: var(--text);
}

.profile-screen.profile-editor {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.profile-screen-header {
  min-height: 48px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(44px, auto);
  align-items: center;
  gap: 8px;
}

.profile-screen-header strong {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.04rem;
}

.profile-screen-header .button {
  min-height: 38px;
  padding: 0 14px;
}

.profile-hero {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: color-mix(in srgb, var(--panel-2) 82%, #fff 8%);
  text-align: center;
}

.profile-hero.compact {
  padding: 16px 12px;
}

.profile-hero-avatar {
  width: 104px;
  height: 104px;
  flex-basis: 104px;
  border: 3px solid color-mix(in srgb, var(--gold) 58%, transparent);
  font-size: 1.3rem;
}

button.profile-hero-avatar {
  cursor: pointer;
}

button.profile-hero-avatar:disabled {
  cursor: default;
}

.profile-hero h2 {
  max-width: 100%;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 1.28rem;
  line-height: 1.15;
}

.profile-hero p {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.profile-bio,
.profile-viewer-bio {
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

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

.profile-info-card {
  display: grid;
  gap: 8px;
}

.profile-info-card > div {
  min-height: 56px;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.profile-info-card span,
.profile-editor label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-info-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.profile-editor label {
  display: grid;
  gap: 6px;
}

.profile-editor input,
.profile-editor textarea {
  width: 100%;
  border-radius: 18px;
}

.profile-editor textarea {
  min-height: 96px;
  resize: vertical;
}

.own-profile-viewer {
  --profile-bg: color-mix(in srgb, var(--panel) 94%, #fff 6%);
  --profile-card: color-mix(in srgb, var(--panel-2) 88%, #fff 5%);
  --profile-card-soft: color-mix(in srgb, var(--panel-2) 86%, #fff 8%);
  --profile-text: var(--text);
  --profile-muted: var(--muted);
  --profile-line: var(--line);
  --profile-accent: var(--cyan);
  width: min(500px, calc(100vw - 28px));
  display: block;
  justify-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: var(--profile-bg);
  color: var(--profile-text);
}

.public-profile-viewer,
.profile-qr-viewer {
  --profile-bg: color-mix(in srgb, var(--panel) 94%, #fff 6%);
  --profile-card: color-mix(in srgb, var(--panel-2) 88%, #fff 5%);
  --profile-card-soft: color-mix(in srgb, var(--panel-2) 86%, #fff 8%);
  --profile-text: var(--text);
  --profile-muted: var(--muted);
  --profile-line: var(--line);
  --profile-accent: var(--cyan);
  width: min(500px, calc(100vw - 28px));
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--profile-bg);
  color: var(--profile-text);
}

.profile-modal-screen {
  min-height: auto;
  max-height: inherit;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 0;
  overflow: hidden;
  padding: 0;
  background: transparent;
  color: var(--profile-text, var(--text));
}

.profile-scroll {
  min-height: 0;
  max-height: calc(min(760px, var(--app-viewport-height, 100dvh) - 32px) - var(--profile-header-height));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-padding-top: var(--profile-header-height);
  scroll-padding-bottom: calc(var(--app-safe-bottom) + 24px);
}

.profile-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.profile-modal-header {
  min-height: var(--profile-header-height);
  position: relative;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
  align-items: center;
  gap: 6px;
  padding: calc(var(--app-safe-top) + 4px) calc(var(--app-safe-right) + 10px) 4px calc(var(--app-safe-left) + 10px);
  border-bottom: 1px solid color-mix(in srgb, var(--profile-line) 70%, transparent);
  background: color-mix(in srgb, var(--profile-bg, var(--panel)) 96%, transparent);
  backdrop-filter: blur(18px);
}

.profile-modal-header > strong {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.04rem;
}

.profile-header-spacer {
  width: 44px;
  height: 44px;
}

.profile-modal-tools {
  display: inline-flex;
  justify-content: flex-end;
  gap: 4px;
}

.profile-icon-action,
.profile-save-action {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--profile-text);
  touch-action: manipulation;
}

.profile-icon-action {
  width: 44px;
  display: grid;
  place-items: center;
}

.profile-icon-action:hover,
.profile-icon-action:focus-visible,
.profile-icon-action:active,
.profile-save-action:hover,
.profile-save-action:focus-visible,
.profile-save-action:active {
  background: color-mix(in srgb, var(--profile-card-soft) 78%, transparent);
  outline: none;
}

.profile-icon-action svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.1;
}

.profile-save-action {
  padding: 0 10px;
  color: var(--profile-accent);
  font-weight: 800;
  font-size: 0.96rem;
}

.profile-cancel-action {
  color: var(--profile-muted);
}

.profile-save-action:disabled {
  opacity: 0.62;
}

.profile-modal-hero {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 18px 22px;
}

.profile-modal-hero .profile-hero-avatar {
  width: 104px;
  height: 104px;
  flex-basis: 104px;
  border-color: color-mix(in srgb, var(--profile-line) 72%, transparent);
}

.profile-modal-hero h2 {
  margin-top: 8px;
  color: var(--profile-text);
  font-size: clamp(1.28rem, 4.4vw, 1.42rem);
  font-weight: 800;
}

.online-text {
  color: var(--profile-muted) !important;
  font-size: 0.96rem;
}

.profile-details-list,
.profile-edit-list {
  width: 100%;
  display: grid;
  justify-self: stretch;
  box-sizing: border-box;
  margin: 0;
  overflow: visible;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--profile-line) 74%, transparent);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.profile-detail-row,
.profile-edit-row {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--profile-line, color-mix(in srgb, var(--line) 82%, transparent));
}

.profile-detail-row:last-child,
.profile-edit-row:last-child {
  border-bottom: 0;
}

.profile-detail-row > div,
.profile-edit-row {
  min-width: 0;
}

.profile-detail-row strong,
.profile-detail-row span,
.profile-edit-row span,
.profile-edit-row input,
.profile-edit-row small {
  min-width: 0;
}

.profile-detail-row strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--profile-text, var(--text));
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.28;
}

.profile-detail-row span {
  display: block;
  margin: 5px 0 0;
  color: var(--profile-muted, var(--muted));
  font-size: 0.82rem;
  text-transform: none;
}

.profile-detail-row.multiline strong {
  white-space: pre-wrap;
  line-height: 1.42;
}

.profile-detail-row .muted-value {
  color: var(--profile-muted, var(--muted));
  font-weight: 600;
}

.profile-detail-row a {
  color: var(--profile-accent, var(--cyan));
  text-decoration: none;
}

.profile-detail-row .accent-text {
  color: var(--profile-accent, var(--cyan));
}

.profile-row-icon {
  border: 0;
  border-radius: 12px;
  background: transparent;
  width: 30px;
  height: 30px;
  display: grid !important;
  place-items: center;
  color: var(--profile-accent, var(--cyan)) !important;
  cursor: pointer;
}

.profile-row-icon:hover,
.profile-row-icon:focus-visible {
  background: color-mix(in srgb, var(--profile-card-soft) 78%, transparent);
  outline: none;
}

.profile-row-icon svg {
  width: 22px;
  height: 22px;
}

.profile-loading .skeleton-circle {
  border: 1px solid var(--profile-line);
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent),
    var(--profile-card);
}

.profile-qr-screen .profile-scroll {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 12px calc(var(--app-safe-right) + 24px) calc(var(--app-safe-bottom) + 24px) calc(var(--app-safe-left) + 24px);
}

.profile-qr-card {
  --qr-card-start: #101a24;
  --qr-card-end: #1f2d3a;
  --qr-card-text: #f8fbff;
  --qr-card-accent: var(--gold);
  width: min(360px, 100%);
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 20px 20px 22px;
  border: 1px solid color-mix(in srgb, var(--profile-line) 60%, transparent);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--qr-card-accent) 28%, transparent), transparent 34%),
    linear-gradient(145deg, var(--qr-card-start), var(--qr-card-end));
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.26);
  color: var(--qr-card-text);
}

.profile-qr-avatar {
  width: 76px;
  height: 76px;
  flex-basis: 76px;
  margin-bottom: -4px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.profile-qr-art {
  position: relative;
  width: min(300px, 72vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 28px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(10, 16, 24, 0.05), 0 12px 30px rgba(0, 0, 0, 0.18);
}

.profile-qr-code {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.profile-qr-code svg,
.profile-qr-style-preview svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: initial;
  stroke: none;
  color: initial;
  overflow: visible;
}

.profile-qr-code .profile-qr-bg,
.profile-qr-style-preview .profile-qr-bg {
  fill: #fff;
  stroke: none;
}

.profile-qr-code .profile-qr-modules,
.profile-qr-style-preview .profile-qr-modules {
  stroke: none;
  opacity: 1;
}

.profile-qr-center-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--cyan), var(--gold));
  box-shadow: 0 0 0 8px #fff, 0 8px 18px rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: clamp(0.72rem, 3vw, 1rem);
  font-weight: 900;
  letter-spacing: 0;
}

.profile-qr-username {
  max-width: 100%;
  color: var(--qr-card-text);
  font-size: clamp(1.3rem, 6vw, 1.72rem);
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: anywhere;
  text-align: center;
}

.profile-qr-style-section {
  width: min(360px, 100%);
  justify-self: center;
  display: grid;
  gap: 10px;
}

.profile-qr-style-section h3 {
  margin: 0;
  color: var(--profile-accent);
  font-size: 0.92rem;
  font-weight: 800;
}

.profile-qr-style-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.profile-qr-style-option {
  min-width: 0;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 6px;
  background: linear-gradient(145deg, var(--qr-card-start), var(--qr-card-end));
  cursor: pointer;
}

.profile-qr-style-option.selected {
  border-color: var(--profile-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--profile-accent) 24%, transparent);
}

.profile-qr-style-preview,
.profile-qr-style-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.profile-qr-empty,
.profile-qr-error {
  width: min(360px, 100%);
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--profile-line) 70%, transparent);
  border-radius: 24px;
  background: var(--profile-card);
  text-align: center;
}

.profile-qr-empty h2,
.profile-qr-empty p {
  margin: 0;
}

.profile-qr-empty p {
  color: var(--profile-muted);
  line-height: 1.45;
}

.profile-qr-actions {
  width: min(360px, 100%);
  justify-self: center;
  display: grid;
  gap: 8px;
}

.profile-qr-actions .button {
  min-height: 48px;
}

@media (max-width: 640px) {
  .profile-qr-screen .profile-scroll {
    padding: 10px max(18px, var(--app-safe-left)) max(20px, var(--app-safe-bottom)) max(18px, var(--app-safe-right));
  }

  .profile-qr-card {
    width: min(100%, 360px);
    padding: 18px;
  }

  .profile-qr-art {
    width: min(280px, 70vw);
    padding: 16px;
  }

  .profile-qr-share-action {
    order: -1;
  }

  .profile-qr-style-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.profile-edit-list {
  border-bottom: 1px solid color-mix(in srgb, var(--profile-line) 74%, transparent);
  background: color-mix(in srgb, var(--profile-card) 78%, transparent);
}

.profile-edit-row {
  grid-template-columns: 108px minmax(0, 1fr);
}

.profile-edit-row > span {
  color: var(--profile-text, var(--text));
  font-size: 0.94rem;
  font-weight: 650;
}

.profile-edit-row input {
  height: 42px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--profile-accent, var(--cyan));
  text-align: right;
  font-size: 0.96rem;
}

.profile-edit-row .field-hint {
  grid-column: 2;
  text-align: right;
}

.profile-bio-editor {
  width: calc(100% - 56px);
  position: relative;
  display: block !important;
  box-sizing: border-box;
  margin: 14px 28px 0;
  padding: 18px 24px;
  border: 1px solid color-mix(in srgb, var(--profile-line) 74%, transparent);
  border-radius: 26px;
  background: var(--profile-card);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.profile-bio-editor textarea {
  min-height: 82px;
  border: 0;
  border-radius: 0;
  padding: 0 44px 0 0;
  background: transparent;
  color: var(--profile-text, var(--text));
  line-height: 1.42;
  resize: vertical;
}

.profile-counter {
  position: absolute;
  top: 19px;
  right: 24px;
  color: var(--profile-muted, var(--muted));
  font-size: 0.78rem;
}

.profile-editor-hint {
  margin: 0 28px;
  padding: 8px 6px 10px;
  border: 0;
  background: transparent;
  color: var(--profile-muted, var(--muted));
  font-size: 0.84rem;
  line-height: 1.35;
}

.profile-avatar-edit-button {
  position: relative;
  overflow: visible;
}

.profile-avatar-edit-button img {
  border-radius: 50%;
}

.profile-camera-badge {
  position: absolute;
  right: -4px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 3px solid var(--profile-bg, var(--panel));
  border-radius: 50%;
  background: color-mix(in srgb, var(--profile-accent) 82%, #fff 18%);
  color: #fff;
}

.profile-camera-badge svg {
  width: 20px;
  height: 20px;
}

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

.pull-refresh {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.pull-refresh svg {
  width: 18px;
  height: 18px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 8;
  min-height: var(--app-bottom-nav-height);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px calc(var(--app-safe-right) + 10px) calc(var(--app-safe-bottom) + 6px) calc(var(--app-safe-left) + 10px);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-width: 0;
  position: relative;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.bottom-nav button.active {
  color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
}

.bottom-nav svg {
  width: 23px;
  height: 23px;
}

.bottom-nav small {
  position: absolute;
  top: 7px;
  right: calc(50% - 28px);
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 86%, var(--panel));
  color: #111927;
  font-size: 0.68rem;
}

.chat-panel {
  height: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.empty-chat {
  margin: auto;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.empty-logo {
  width: 74px;
  height: 74px;
  flex-basis: 74px;
}

.chat-view {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  position: relative;
  display: grid;
  grid-template-rows: min-content min-content minmax(0, 1fr) min-content min-content min-content;
  overflow: hidden;
  align-items: stretch;
}

.back-button {
  display: none;
}

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

.chat-header {
  grid-row: 1;
}

.group-add-reminder {
  grid-row: 2;
}

#messages {
  grid-row: 3;
}

.edit-banner {
  grid-row: 4;
}

.attachment-preview {
  grid-row: 5;
}

#messageForm {
  grid-row: 6;
}

#activeAvatar,
#activeName {
  cursor: pointer;
}

.messages {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 18px calc(18px + var(--app-safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.day-divider {
  align-self: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.74rem;
}

.unread-divider {
  align-self: center;
  width: min(92%, 420px);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: color-mix(in srgb, var(--cyan) 35%, transparent);
}

.unread-divider span {
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 12%, var(--panel));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}

.unread-jump-button {
  position: absolute;
  right: max(14px, var(--app-safe-right));
  bottom: calc(86px + var(--app-safe-bottom) + var(--keyboard-inset, 0px));
  z-index: 8;
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--cyan) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, var(--cyan) 12%);
  color: var(--cyan);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  font-weight: 900;
}

.unread-jump-button[hidden] {
  display: none;
}

.unread-jump-arrow {
  font-size: 1.2rem;
  line-height: 1;
}

.unread-jump-count {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--cyan);
  color: #071016;
  font-size: 0.72rem;
  line-height: 1;
}

.message-row {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  overflow-anchor: none;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.theirs {
  justify-content: flex-start;
}

.group-add-reminder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--panel) 78%, var(--cyan) 10%);
  border-bottom: 1px solid var(--line);
}

.group-add-reminder[hidden] {
  display: none;
}

.group-add-reminder button:first-child {
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--cyan) 26%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 10%, var(--panel));
  color: var(--cyan);
  font-weight: 900;
}

.message-row.unread-target-highlight .message {
  animation: unread-target-pulse 1.8s ease-out;
}

@keyframes unread-target-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--cyan) 34%, transparent);
    background-color: color-mix(in srgb, var(--cyan) 16%, var(--panel-2));
  }
  45% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--cyan) 10%, transparent);
  }
  100% {
    box-shadow: var(--shadow);
  }
}

.message-avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  margin-bottom: 2px;
  font-size: 0.7rem;
}

.message {
  width: fit-content;
  max-width: min(68%, 680px);
  min-width: 0;
  overflow-wrap: anywhere;
  position: relative;
  touch-action: manipulation;
  padding: 9px 11px 7px;
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.message.mine {
  align-self: flex-end;
  background: #d6b15f;
  color: #111927;
}

.message.theirs {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
}

.message.deleted {
  opacity: 0.72;
}

.deleted-text {
  color: var(--muted);
  font-style: italic;
}

.message-action {
  position: absolute;
  top: -10px;
  right: -8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel) 88%, #fff 12%);
  color: inherit;
  opacity: 0;
}

.message:hover .message-action,
.message:focus-within .message-action {
  opacity: 1;
}

.message.mine .message-action {
  opacity: 0;
}

.message .sender {
  display: block;
  margin-bottom: 4px;
  color: var(--sender-name-color, var(--cyan));
  font-size: 0.75rem;
  font-weight: 800;
}

.message.mine .sender {
  color: #111927;
  opacity: 0.72;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.42;
}

.message a {
  color: inherit;
}

.message time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
  text-align: right;
  font-size: 0.72rem;
}

.message time > span:not(.message-status) {
  opacity: 0.68;
}

.message-status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 16px;
  opacity: 0.95;
}

.ticks {
  display: inline-flex;
  align-items: center;
  color: currentColor;
}

.ticks svg {
  width: 12px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2.4;
}

.ticks.double svg + svg {
  margin-left: -6px;
}

.message-status.read {
  color: var(--cyan);
  opacity: 1;
}

.edit-banner {
  align-self: end;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--cyan) 9%, var(--panel));
  color: var(--text);
}

.edit-banner span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cyan);
  font-weight: 800;
}

.attachment {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.attachment-media {
  width: min(360px, 100%);
  aspect-ratio: var(--media-ratio, 4 / 3);
  max-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #000;
  color: inherit;
}

.attachment-media img,
.attachment-media video {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: inherit;
  background: #000;
}

.attachment-image {
  text-decoration: none;
}

.file-card {
  min-width: min(300px, 76vw);
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
}

.file-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, currentColor 10%, transparent);
  font-weight: 800;
}

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

.file-card span {
  display: block;
  opacity: 0.72;
  font-size: 0.76rem;
}

.attachment-preview {
  align-self: end;
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.preview-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  align-self: end;
  display: flex;
  gap: 10px;
  align-items: end;
  align-content: end;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 12px max(12px, var(--app-safe-bottom));
  margin-bottom: var(--keyboard-inset, 0px);
  border-top: 0;
  background: color-mix(in srgb, var(--bg) 86%, var(--panel) 14%);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.composer textarea {
  flex: 1 1 auto;
  display: block;
  align-self: end;
  min-width: 0;
  width: auto;
  max-width: 100%;
  height: 46px;
  min-height: 46px;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: none;
  line-height: 1.35;
  border-radius: var(--radius-md);
  -webkit-appearance: none;
}

.composer textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.composer .icon-button {
  flex: 0 0 42px;
  align-self: end;
}

.emoji-wrap {
  flex: 0 0 42px;
  min-width: 0;
  align-self: end;
}

.emoji-wrap {
  position: relative;
}

.emoji-toggle {
  font-size: 1.15rem;
  line-height: 1;
}

.emoji-panel {
  position: fixed;
  left: 12px;
  top: 12px;
  width: min(300px, calc(100vw - 16px));
  max-height: min(320px, calc(100dvh - 24px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 40;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.emoji-panel[hidden] {
  display: none !important;
}

.emoji-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.emoji-choice {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--panel-2);
  font-size: 1.15rem;
}

.emoji-choice:hover {
  background: var(--panel-3);
}

.sheet-layer,
.profile-viewer-layer,
.group-create-layer,
.group-panel-layer,
.avatar-crop-layer,
.avatar-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.sheet-layer {
  z-index: 120;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.action-sheet,
.profile-viewer,
.group-create-card,
.avatar-crop-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 32px));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--panel) 94%, #fff 6%);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.44);
}

.action-sheet {
  padding: 14px;
}

.action-sheet > strong {
  display: block;
  padding: 8px 10px 12px;
  color: var(--muted);
}

.sheet-actions {
  display: grid;
  gap: 6px;
}

.sheet-action {
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 18px;
  padding: 11px 12px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.sheet-action:hover {
  background: var(--panel-3);
}

.sheet-action.danger-row {
  color: var(--danger);
}

.sheet-action svg {
  width: 21px;
  height: 21px;
}

.profile-viewer,
.group-create-card,
.avatar-crop-card {
  padding: 18px;
}

.profile-viewer {
  padding: 0;
  overflow: hidden;
}

.group-create-card {
  width: min(520px, calc(100vw - 28px));
  min-height: min(520px, calc(100dvh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
}

.group-create-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #fff 6%);
}

.group-create-header strong {
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.06rem;
}

.compact-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
}

.group-create-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px;
}

.group-create-search {
  height: 42px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
}

.group-create-search .search-icon svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.group-create-search input {
  min-width: 0;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.94rem;
  outline: none;
}

.group-create-selected {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 12px;
}

.group-create-selected[hidden] {
  display: none;
}

.group-create-chip {
  min-width: 74px;
  display: grid;
  justify-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
}

.group-create-chip .avatar {
  width: 46px;
  height: 46px;
}

.group-create-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.group-create-list.compact {
  margin-top: 0;
}

.group-create-contact {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.group-create-contact.static {
  grid-template-columns: 46px minmax(0, 1fr);
}

.group-create-contact.selected {
  border-color: color-mix(in srgb, var(--cyan) 48%, var(--line));
  background: color-mix(in srgb, var(--cyan) 9%, var(--panel));
}

.group-create-check {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 16%, var(--panel-2));
  color: var(--cyan);
  font-weight: 900;
}

.group-create-details {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
}

.group-create-avatar {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  overflow: hidden;
  background: color-mix(in srgb, var(--cyan) 20%, var(--panel-2));
  color: var(--cyan);
}

.group-create-avatar svg {
  width: 32px;
  height: 32px;
}

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

.group-create-title-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.group-create-title-field input {
  height: 42px;
  border-width: 0 0 1px;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
}

.group-create-avatar-remove {
  align-self: start;
}

.group-panel-layer {
  background: color-mix(in srgb, var(--bg) 82%, #000 18%);
}

.group-panel {
  width: 100%;
  height: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.group-panel-header {
  min-height: 62px;
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 8px;
  padding: max(8px, var(--app-safe-top)) 12px 8px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #fff 6%);
}

.group-panel-header strong {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
}

.group-panel-tools {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.group-menu-popover {
  position: fixed;
  z-index: 2200;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 96%, #fff 4%);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.group-menu-popover-item {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
  font: inherit;
  font-weight: 700;
}

.group-menu-popover-item:hover {
  background: var(--panel-2);
}

.group-menu-popover-item:disabled {
  cursor: default;
  opacity: 0.52;
}

.group-menu-popover-item.danger {
  color: var(--danger);
}

.group-menu-popover-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: var(--cyan);
}

.group-menu-popover-item.danger .group-menu-popover-icon {
  color: var(--danger);
}

.group-menu-popover-icon svg {
  width: 21px;
  height: 21px;
}

.group-panel-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px max(24px, var(--app-safe-bottom));
}

.group-hero {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 18px 12px;
  border-bottom: 1px solid var(--line);
}

.group-hero.compact {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
}

.group-hero .avatar {
  width: 112px;
  height: 112px;
  flex-basis: 112px;
  border: 3px solid color-mix(in srgb, var(--gold) 55%, transparent);
  font-size: 1.5rem;
}

.group-hero h2 {
  margin: 4px 0 0;
  text-align: center;
  font-size: 1.32rem;
}

.group-hero p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.group-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.group-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.group-badge.accent {
  background: color-mix(in srgb, var(--cyan) 14%, var(--panel));
  color: var(--cyan);
}

.group-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 0;
}

.group-quick-actions button,
.group-list-row,
.group-settings-row {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
}

.group-quick-actions button {
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.group-quick-actions button:disabled,
.group-settings-row:disabled,
.group-list-row:disabled {
  opacity: 0.48;
}

.group-quick-actions svg,
.group-settings-row svg {
  width: 22px;
  height: 22px;
  color: var(--cyan);
}

.group-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.group-member-search,
.group-form textarea,
.group-form input[type="text"] {
  width: 100%;
  border-radius: 18px;
}

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

.group-list-row {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}

.group-list-row .avatar {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
  font-size: 0.85rem;
}

.group-list-main {
  min-width: 0;
}

.group-list-main strong,
.group-list-main small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-list-main small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.group-role-badge {
  border-radius: 999px;
  padding: 5px 8px;
  background: color-mix(in srgb, var(--gold) 16%, var(--panel));
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 900;
}

.group-role-badge.muted {
  background: var(--panel-2);
  color: var(--muted);
}

.group-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.group-member-menu-button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  font-size: 1.18rem;
  line-height: 1;
}

.group-form {
  display: grid;
  gap: 14px;
}

.group-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.group-form textarea {
  min-height: 104px;
  resize: vertical;
}

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

.group-settings-row {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

.group-settings-row small {
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.group-settings-row.danger {
  color: var(--danger);
}

.group-toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.group-toggle-row strong,
.group-toggle-row small {
  display: block;
}

.group-toggle-row small {
  color: var(--muted);
  font-size: 0.76rem;
}

.group-toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--cyan);
}

.group-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.group-retry-button {
  width: auto;
  margin: 12px auto 0;
  padding: 0 18px;
}

@media (min-width: 760px) {
  .group-panel-layer {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .group-panel {
    height: min(860px, calc(100dvh - 48px));
    border: 1px solid var(--line);
    border-radius: 30px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.44);
  }
}

.profile-viewer {
  width: min(500px, calc(100vw - 28px));
  display: block;
  overflow: hidden;
  padding: 0;
  color: var(--text);
}

.profile-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.profile-viewer-avatar {
  width: 104px;
  height: 104px;
  flex-basis: 104px;
  border: 2px solid color-mix(in srgb, var(--line) 72%, transparent);
  font-size: 1.4rem;
}

.profile-viewer h2 {
  margin: 0;
  text-align: center;
  font-size: 1.3rem;
}

.profile-viewer-muted {
  margin: -4px 0 0;
  color: var(--muted);
}

.profile-lines {
  width: 100%;
  display: grid;
  gap: 0;
}

.profile-lines > div,
.profile-member-row {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 12px 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.profile-lines span,
.profile-member-row small {
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-viewer-actions {
  width: calc(100% - 56px);
  display: flex;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 28px 16px;
}

.profile-viewer-actions .button {
  flex: 1 1 0;
  width: auto;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 0.86rem;
}

.profile-viewer-actions .button:only-child {
  grid-column: 1 / -1;
}

.profile-viewer-actions.group-actions {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.group-info-list {
  max-height: 300px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.group-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
}

.profile-member-row {
  grid-template-columns: 44px 1fr;
  align-items: center;
  border: 0;
  color: var(--text);
  text-align: left;
}

.group-member-row > button:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.profile-member-row .avatar {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
}

.avatar-crop-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.crop-stage {
  width: min(320px, calc(100vw - 64px));
  height: min(320px, calc(100vw - 64px));
  position: relative;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.crop-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.crop-ring {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  pointer-events: none;
}

.crop-zoom {
  margin: 0 0 14px;
}

.crop-zoom input {
  padding: 0;
}

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

.avatar-image-viewer {
  z-index: 70;
  display: grid;
  place-items: center;
  padding: max(18px, var(--app-safe-top)) max(18px, var(--app-safe-right)) max(18px, var(--app-safe-bottom)) max(18px, var(--app-safe-left));
  background: rgba(0, 0, 0, 0.88);
}

.avatar-image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 24px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.5);
}

.viewer-close {
  position: fixed;
  top: max(14px, var(--app-safe-top));
  right: max(14px, var(--app-safe-right));
  z-index: 2;
}

.call-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: block;
  padding: 0;
  background: #000;
}

.call-card {
  width: 100vw;
  height: 100dvh;
  min-height: 100svh;
  position: relative;
  background: #000;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
}

.call-topline {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: max(14px, var(--app-safe-top)) 14px 14px;
  border-bottom: 0;
  background: linear-gradient(rgba(0, 0, 0, 0.72), transparent);
}

.call-avatar {
  width: 54px;
  height: 54px;
  flex-basis: 54px;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.call-topline span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.video-grid {
  width: 100%;
  height: 100%;
  position: relative;
  display: block;
  padding: 0;
}

video {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background: #000;
  object-fit: cover;
  border-radius: 0;
}

#remoteVideo {
  position: absolute;
  inset: 0;
}

#localVideo {
  position: absolute;
  right: max(12px, var(--app-safe-right));
  top: max(92px, calc(var(--app-safe-top) + 78px));
  z-index: 2;
  width: min(34vw, 180px);
  height: auto;
  aspect-ratio: 9 / 14;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  cursor: grab;
  touch-action: none;
}

#localVideo.dragging {
  cursor: grabbing;
}

.call-controls,
.incoming-actions {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: max(18px, var(--app-safe-bottom));
  display: flex;
  gap: 10px;
  padding: 0 14px;
}

.call-controls {
  justify-content: center;
  align-items: center;
}

.incoming-actions {
  display: grid;
  grid-template-columns: 76px 76px 76px;
  justify-content: center;
  gap: 18px;
  bottom: max(88px, calc(var(--app-safe-bottom) + 78px));
}

.incoming-actions.audio-only {
  grid-template-columns: 76px 76px;
  gap: 28px;
}

.call-action {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.call-action svg {
  width: 32px;
  height: 32px;
  stroke-width: 2.2;
}

.call-action.accept {
  background: #22c55e;
}

.call-action.accept-audio {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.call-action.decline {
  background: #ef4444;
}

.call-action.decline svg {
  transform: rotate(135deg);
}

.hangup-call {
  order: 2;
  width: 68px;
  height: 68px;
  flex-basis: 68px;
  border-radius: 50%;
}

.hangup-call svg {
  width: 32px;
  height: 32px;
  transform: rotate(135deg);
}

#muteButton {
  order: 1;
}

#cameraButton {
  order: 3;
}

#speakerButton {
  display: none;
}

.toast-area {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 8px;
  z-index: 30;
}

.toast {
  max-width: min(360px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .messenger-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
  }

  .chat-panel {
    display: none;
  }

  body.chat-open .sidebar {
    display: none;
  }

  body.chat-open .chat-panel {
    display: grid;
    height: var(--app-viewport-height, 100dvh);
    min-height: 0;
    max-height: var(--app-viewport-height, 100dvh);
    overflow: hidden;
  }

  .back-button {
    display: grid;
  }

  .profile-section {
    display: none;
  }

  .contacts-section,
  .groups-section {
    flex: 0 0 auto;
  }

  .people-section {
    flex: 0 0 auto;
  }

  .family-section {
    flex: 0 0 auto;
  }

  .list-section {
    flex: 1;
    min-height: 0;
    padding-bottom: 8px;
  }

  .quick-menu {
    top: auto;
    left: max(8px, var(--app-safe-left));
    right: max(8px, var(--app-safe-right));
    bottom: max(8px, var(--app-safe-bottom));
    width: auto;
    max-height: min(82dvh, 720px);
    border-radius: 30px;
    padding-bottom: max(12px, var(--app-safe-bottom));
  }

  .action-sheet,
  .profile-viewer,
  .group-create-card,
  .avatar-crop-card {
    left: max(8px, var(--app-safe-left));
    right: max(8px, var(--app-safe-right));
    top: auto;
    bottom: max(8px, var(--app-safe-bottom));
    width: auto;
    max-height: min(86dvh, 760px);
    transform: none;
    border-radius: 30px;
  }

  .profile-viewer.own-profile-viewer {
    inset: 0;
    width: 100vw;
    height: var(--app-viewport-height, 100dvh);
    max-height: var(--app-viewport-height, 100dvh);
    border-radius: 0;
  }

  .own-profile-viewer .profile-modal-screen {
    min-height: 0;
    max-height: inherit;
    padding-bottom: 0;
  }

  .profile-viewer {
    inset: 0;
    width: 100vw;
    height: var(--app-viewport-height, 100dvh);
    max-height: var(--app-viewport-height, 100dvh);
    border-radius: 0;
  }

  .profile-scroll {
    max-height: none;
    padding-bottom: calc(var(--app-safe-bottom) + 12px);
  }

  .group-create-card {
    min-height: min(86dvh, 760px);
  }

  .profile-viewer-actions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    gap: 8px;
    flex: 0 0 auto;
  }

  #localVideo {
    width: min(36vw, 150px);
    top: max(86px, calc(var(--app-safe-top) + 72px));
  }
}

@media (max-width: 420px) {
  .sidebar-header,
  .chat-header {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .composer {
    padding-left: 8px;
    padding-right: 8px;
  }

  .composer .icon-button,
  .emoji-wrap {
    flex-basis: 40px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .messenger-view {
    grid-template-columns: minmax(300px, 38vw) 1fr;
  }

  .sidebar-header,
  .chat-header {
    min-height: calc(58px + var(--app-safe-top));
    padding-top: calc(var(--app-safe-top) + 8px);
    padding-bottom: 8px;
  }

  .profile-section {
    display: none;
  }

  .chat-item,
  .member-item {
    min-height: 54px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .messages {
    padding: 10px;
  }

  .composer {
    padding-top: 8px;
    padding-bottom: max(8px, var(--app-safe-bottom));
  }

  video {
    max-height: none;
  }
}
