:root {
  --bg: #edf2f7;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --line: #d9e2ec;
  --text: #102033;
  --muted: #607086;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #dff8f3;
  --danger: #ef4444;
  --warning: #b08922;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.11);
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.session-restoring .auth-screen,
.session-restoring .app-shell {
  display: none;
}

body:not(.session-restoring) .boot-screen {
  display: none;
}

.auth-active .app-shell {
  display: none;
}

body:not(.auth-active) .auth-screen {
  display: none;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 30px 20px;
  background:
    linear-gradient(125deg, rgba(20, 184, 166, 0.1) 0%, rgba(20, 184, 166, 0.1) 36%, transparent 36.2%),
    linear-gradient(305deg, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0.08) 31%, transparent 31.2%),
    #eef3f8;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  background:
    linear-gradient(180deg, #f8fbfd 0%, #edf4f8 100%),
    var(--bg);
  font-size: 14px;
  font-weight: 800;
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-row.compact {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: #053b35;
  background: linear-gradient(135deg, #77e7cd, #3fcfb2);
  font-weight: 900;
  box-shadow: inset 0 -10px 18px rgba(15, 118, 110, 0.1);
}

.brand-mark.small {
  width: 48px;
  height: 48px;
}

.connection-text,
.section-title,
.profile-status,
.chat-subtitle,
.room-last,
.message-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-card .connection-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.auth-card .connection-text::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.connection-text,
.section-title {
  color: var(--primary);
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

.auth-card h1 {
  margin-top: 3px;
  color: #0f172a;
  font-size: 27px;
  font-weight: 950;
}

.auth-card label {
  display: block;
  margin: 15px 0 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
}

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

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

.auth-card input {
  height: 46px;
  border-color: #cfd9e6;
  border-radius: 8px;
  background: #fbfdff;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.auth-card input::placeholder {
  color: #8a98aa;
}

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

input:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.65);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.auth-card input:focus {
  background: #fff;
  border-color: rgba(15, 118, 110, 0.78);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.11);
}

.form-error {
  min-height: 18px;
  margin: 8px 0 10px;
  color: var(--danger);
  font-size: 13px;
}

.primary-button,
.ghost-button,
.danger-button,
.back-button,
.icon-button {
  border: 0;
  border-radius: 10px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.auth-card .primary-button {
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

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

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

.auth-card .ghost-button {
  border-color: #cfd9e6;
  border-radius: 8px;
  color: var(--primary);
  background: #f8fffd;
  font-size: 14px;
}

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

.full-button {
  width: 100%;
  height: 46px;
}

.auth-card .full-button {
  height: 46px;
  margin-top: 2px;
  font-size: 16px;
}

.compact-button {
  height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--primary);
  font-size: 24px;
  line-height: 1;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 24px 0 20px;
  padding: 4px;
  border: 1px solid #dbe5f0;
  border-radius: 8px;
  background: #f1f6fb;
}

.auth-tab {
  height: 36px;
  border: 0;
  border-radius: 6px;
  color: #526276;
  background: transparent;
  font-weight: 900;
  transition:
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.auth-tab.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
}

.auth-extra label {
  margin-top: 15px;
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.auth-code-row input {
  min-width: 0;
}

.auth-code-row .compact-button {
  height: 44px;
  padding: 0 12px;
}

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: var(--app-height);
  min-height: 0;
  overflow: hidden;
}

.app-page {
  min-height: 0;
}

.chat-page {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

body.page-chat .me-page,
body.page-chat .game-page,
body.page-me .chat-page,
body.page-me .game-page,
body.page-game .chat-page,
body.page-game .me-page {
  display: none;
}

body.page-game .main-tabbar {
  display: none;
}

.game-page {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #07120f;
}

.game-exit-button {
  position: absolute;
  z-index: 4;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #f8fffd;
  background: rgba(7, 18, 15, 0.72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(14px);
  font-size: 14px;
  font-weight: 900;
}

.game-exit-button.hidden {
  display: none;
}

.game-exit-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.game-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #07120f;
}

.me-page {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px min(5vw, 64px);
  background: var(--panel-soft);
}

.me-page-inner {
  display: grid;
  max-width: 920px;
  margin: 0 auto;
  gap: 18px;
}

.me-hero,
.me-section {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
}

.me-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border-radius: 18px;
}

.me-avatar {
  width: 72px;
  height: 72px;
  font-size: 22px;
}

.me-hero-copy {
  min-width: 0;
  margin-right: auto;
}

.me-hero h2 {
  margin-top: 4px;
  color: #0f172a;
  font-size: 30px;
  font-weight: 950;
}

.me-hero p {
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-card {
  display: grid;
  gap: 16px;
}

.me-section {
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 16px;
}

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

.me-section h3 {
  margin: 4px 0 0;
  color: #102033;
  font-size: 19px;
  line-height: 1.2;
}

.me-section label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.me-section input[type="file"] {
  height: auto;
  padding: 10px 12px;
  background: #fbfdff;
}

.main-tabbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 14px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.main-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 52px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.main-tab.active {
  color: var(--primary-strong);
  border-color: rgba(15, 118, 110, 0.22);
  background: var(--primary-soft);
}

.main-tab-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  color: inherit;
  background: rgba(15, 118, 110, 0.1);
  font-size: 13px;
  font-weight: 950;
}

.rooms-pane,
.chat-pane {
  min-height: 0;
  background: var(--panel);
}

.rooms-pane {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--line);
}

.profile-name {
  max-width: 210px;
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.home-tools .ghost-button {
  flex: 0 0 auto;
}

.search-input {
  border-radius: 12px;
  background: #fff;
}

.room-section {
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.section-title {
  margin: 0 6px 8px;
  font-size: 13px;
}

.room-list {
  display: grid;
  gap: 2px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  background: #fff;
  text-align: left;
}

.room-item:hover,
.room-item.active {
  border-color: rgba(15, 118, 110, 0.45);
  background: #effdf9;
}

.room-item.not-joined {
  color: #334155;
  border-color: rgba(203, 213, 225, 0.75);
  background: rgba(248, 250, 252, 0.82);
}

.room-item.not-joined:hover {
  border-color: rgba(15, 118, 110, 0.28);
  background: #f6fffc;
}

.room-item:disabled {
  cursor: default;
  opacity: 0.58;
}

.room-item[aria-disabled="true"] {
  opacity: 0.64;
}

.room-item[aria-disabled="true"]:hover {
  border-color: rgba(203, 213, 225, 0.75);
  background: #fff;
}

.thread-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #075e55;
  background: #e0f7f2;
  font-size: 14px;
  font-weight: 950;
}

.brand-mark.has-image,
.thread-avatar.has-image,
.message-avatar.has-image,
.call-avatar.has-image {
  color: transparent;
  background-color: #d9e2ec;
  background-position: center;
  background-size: cover;
}

.thread-avatar.direct {
  color: #fff;
  background: #64748b;
}

.room-main {
  flex: 1 1 auto;
  min-width: 0;
}

.room-name {
  overflow: hidden;
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-last {
  max-width: 100%;
  overflow: hidden;
  margin-top: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.room-pill {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: #075e55;
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 900;
}

.room-pill.call {
  width: auto;
  padding: 0 8px;
  color: #fff;
  background: var(--warning);
}

.room-action {
  display: inline-grid;
  min-width: 48px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  color: #075e55;
  background: #e8fbf6;
  font-size: 13px;
  font-weight: 900;
}

.room-action.leave {
  color: #64748b;
  border-color: rgba(148, 163, 184, 0.34);
  background: #f8fafc;
}

.room-action:hover {
  color: #fff;
  background: var(--primary);
}

.chat-pane {
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 78px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.back-button {
  display: none;
  height: 38px;
  padding: 0 12px;
}

.chat-heading {
  min-width: 0;
  margin-right: auto;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-title {
  overflow: hidden;
  font-size: 22px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-subtitle {
  margin-top: 3px;
}

.call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 22px;
  color: #075e55;
  border-bottom: 1px solid rgba(15, 118, 110, 0.18);
  background: var(--primary-soft);
  font-size: 14px;
  font-weight: 800;
}

.message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 250, 252, 0.98)),
    var(--panel-soft);
}

.empty-state,
.empty-chat {
  color: var(--muted);
  font-size: 14px;
}

.empty-chat {
  display: grid;
  height: 100%;
  place-items: center;
}

.message-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 18px;
  overflow: visible;
}

.message-system-row {
  display: flex;
  justify-content: center;
  margin: 12px auto 18px;
  color: #91a1b4;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
}

.message-system-row::before,
.message-system-row::after {
  content: "";
  width: 22px;
  height: 1px;
  margin: auto 8px;
  background: rgba(145, 161, 180, 0.26);
}

.message-row.mine {
  flex-direction: row-reverse;
}

.message-content {
  display: grid;
  max-width: min(620px, 72%);
  gap: 5px;
  justify-items: start;
}

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

.message-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: #64748b;
  font-size: 13px;
  font-weight: 900;
}

.message-row > .message-avatar {
  margin-top: 20px;
}

.message-row.mine .message-avatar {
  background: var(--primary);
}

.message-bubble {
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.message-row.mine .message-bubble {
  color: #fff;
  border-color: transparent;
  border-radius: 14px 14px 4px 14px;
  background: var(--primary);
}

.message-meta {
  max-width: 100%;
  padding: 0 4px;
  overflow: hidden;
  color: #7c8da5;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row.mine .message-meta {
  color: #8ba0b5;
  text-align: right;
}

.message-text {
  overflow-wrap: anywhere;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message-quote {
  max-width: 100%;
  margin-top: 1px;
  padding: 6px 8px;
  overflow: hidden;
  border-left: 3px solid rgba(15, 118, 110, 0.45);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(15, 118, 110, 0.08);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row.mine .message-quote {
  color: #607086;
  border-left-color: rgba(19, 135, 126, 0.34);
  background: rgba(233, 250, 246, 0.9);
  text-align: left;
}

.message-actions {
  position: fixed;
  z-index: 42;
  top: var(--message-actions-top, 0);
  left: var(--message-actions-left, 0);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: min(320px, calc(100vw - 20px));
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(203, 213, 225, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 18px 44px rgba(15, 23, 42, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px) scale(0.98);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  backdrop-filter: blur(14px);
}

.message-actions::after {
  content: "";
  position: absolute;
  left: 28px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(203, 213, 225, 0.72);
  border-bottom: 1px solid rgba(203, 213, 225, 0.72);
  background: rgba(255, 255, 255, 0.96);
  transform: rotate(45deg);
}

.message-row.mine .message-actions::after {
  right: 28px;
  left: auto;
}

.message-row.actions-open .message-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.message-row.actions-above .message-actions::after {
  bottom: -6px;
}

.message-row.actions-below .message-actions::after {
  top: -6px;
  transform: rotate(225deg);
}

.message-row.mine .message-actions {
  right: auto;
}

.message-actions button {
  height: 31px;
  padding: 0 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
  color: #28405c;
  background: rgba(248, 251, 253, 0.94);
  font-size: 12px;
  font-weight: 900;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.message-row.mine .message-actions button {
  color: #28405c;
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(248, 251, 253, 0.94);
}

.message-actions button:hover {
  color: #075e55;
  border-color: rgba(19, 135, 126, 0.28);
  background: #ecfdf8;
}

.pinned-message-strip {
  position: sticky;
  top: 0;
  z-index: 2;
  max-width: min(620px, calc(100% - 8px));
  margin: 0 auto 12px;
  padding: 9px 12px;
  overflow: hidden;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 14px;
  color: #075e55;
  background: rgba(236, 253, 248, 0.95);
  box-shadow: 0 10px 24px rgba(19, 135, 126, 0.08);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  padding: 14px 22px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.reply-preview {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 800;
}

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

.send-button {
  width: 78px;
  height: 44px;
  flex: 0 0 auto;
}

.members-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.28);
}

.sheet-card {
  width: min(420px, 100%);
  max-height: min(560px, 84dvh);
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.member-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel-soft);
}

.member-item.action-item {
  align-items: center;
}

.member-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card,
.contacts-card,
.group-manage-card,
.search-card {
  display: flex;
  flex-direction: column;
}

.contacts-sheet {
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(4px);
}

.contacts-card {
  width: min(560px, 100%);
  max-height: min(680px, calc(var(--app-height) - 48px));
  border: 1px solid rgba(226, 232, 240, 0.94);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
}

.contacts-header {
  align-items: flex-start;
  padding: 24px 26px 20px;
  background:
    linear-gradient(135deg, rgba(223, 248, 243, 0.96), rgba(255, 255, 255, 0.98) 62%),
    #fff;
}

.contacts-header h2 {
  margin-top: 4px;
  font-size: 26px;
}

.contacts-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.contact-close-button {
  border-radius: 9px;
}

.contacts-search-panel {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.profile-form,
.contacts-tools {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
}

.profile-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.contacts-tools {
  grid-template-columns: minmax(0, 1fr) auto;
}

.contacts-card .contacts-tools {
  padding: 0;
}

.contacts-card .contacts-tools input {
  height: 46px;
  border-radius: 10px;
  background: #fbfdff;
}

.contacts-card .contacts-tools .compact-button {
  height: 46px;
  padding: 0 20px;
  border-radius: 10px;
}

.contacts-content {
  display: grid;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 24px;
  background: #f8fafc;
}

.contacts-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.contacts-section-title {
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 900;
}

.contacts-card .contact-list {
  max-height: none;
  overflow: visible;
  padding: 0;
}

.contacts-card .empty-state {
  min-height: 48px;
  padding: 13px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.72);
}

.contact-item {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
}

.contact-info {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 3px;
}

.contact-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.contact-item .compact-button {
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
}

.contact-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(20, 132, 116, 0.14);
  border-radius: 999px;
  color: var(--primary-strong);
  background: rgba(226, 247, 242, 0.82);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.contact-item .compact-button:disabled {
  cursor: not-allowed;
  color: #94a3b8;
  border-color: #e2e8f0;
  background: #f8fafc;
  box-shadow: none;
}

.search-result {
  align-items: flex-start;
}

.search-result .member-name {
  white-space: normal;
}

.group-manage-card textarea {
  min-height: 88px;
}

.add-member-panel {
  display: grid;
  gap: 10px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.add-member-panel.hidden {
  display: none;
}

.add-member-panel .selectable-list {
  max-height: 220px;
}

.group-card {
  display: flex;
  flex-direction: column;
}

.group-form {
  display: grid;
  gap: 10px;
  padding: 16px 18px 10px;
}

.group-form label,
.group-member-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.group-helper {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.group-member-head {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.selectable-list {
  max-height: 260px;
  padding: 0;
}

.select-member {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
}

.select-member:hover {
  background: var(--panel-soft);
}

.select-member input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.sheet-footer {
  padding: 10px 18px 18px;
}

.call-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  background: #050816;
}

.call-topbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 16px;
  background: linear-gradient(180deg, rgba(5, 8, 22, 0.9), rgba(5, 8, 22, 0));
}

.call-title {
  font-size: 18px;
  font-weight: 950;
}

.call-state {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.call-tiles {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.call-tiles.video-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 84px 18px 108px;
}

.call-tiles.video-grid[data-grid-size="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.call-tiles.video-grid[data-grid-size="8"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.call-tiles.video-grid[data-grid-size="12"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.call-tile {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  background: #111827;
}

.call-tiles.video-grid .call-tile {
  width: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.call-tiles.video-grid .call-tile.placeholder {
  pointer-events: none;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.06), transparent 34%),
    rgba(15, 23, 42, 0.42);
  box-shadow: none;
}

.call-tile.main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.call-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-avatar {
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  border-radius: 30px;
  color: #fff;
  background: #334155;
  font-size: 34px;
  font-weight: 950;
}

.call-tile.local .call-avatar {
  background: var(--primary);
}

.call-tiles.video-grid .call-avatar {
  width: clamp(72px, 12vw, 118px);
  height: clamp(72px, 12vw, 118px);
  border-radius: clamp(18px, 3vw, 30px);
  font-size: clamp(22px, 4vw, 34px);
}

.call-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  overflow: hidden;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-strip {
  position: absolute;
  top: 86px;
  right: 14px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.call-strip .call-tile {
  width: 116px;
  height: 150px;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.call-strip .call-avatar {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  font-size: 18px;
}

.call-tiles.audio-mode {
  display: grid;
  place-items: center;
  padding: 90px 18px 120px;
}

.call-tiles.audio-mode .call-tile.main {
  position: static;
  width: 260px;
  height: 260px;
  border: 0;
  background: transparent;
}

.call-tiles.audio-mode .call-strip {
  position: static;
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  margin-top: 18px;
}

.call-tiles.audio-mode .call-strip .call-tile {
  width: 82px;
  height: 82px;
}

.call-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 18px 18px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(5, 8, 22, 0.92), rgba(5, 8, 22, 0));
}

.call-button {
  min-width: 86px;
  height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  font-weight: 900;
}

.call-button.danger {
  border-color: transparent;
  background: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 12px;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  body {
    background: var(--panel);
  }

  .auth-screen {
    align-items: start;
    padding: 16px;
  }

  .auth-card {
    width: min(430px, 100%);
    max-height: calc(var(--app-height) - 32px);
    margin: auto 0;
    overflow-y: auto;
    padding: 22px;
    border-radius: 8px;
  }

  .auth-card h1 {
    font-size: 24px;
  }

  .auth-tabs {
    margin: 20px 0 16px;
  }

  .auth-card label {
    margin-top: 12px;
  }

  @media (max-width: 380px) {
    .auth-code-row {
      grid-template-columns: 1fr;
    }
  }

  .contacts-sheet {
    align-items: end;
    padding: 12px;
  }

  .contacts-card {
    width: 100%;
    max-height: min(680px, calc(var(--app-height) - 24px));
    border-radius: 16px;
  }

  .contacts-header {
    padding: 20px 18px 16px;
  }

  .contacts-header h2 {
    font-size: 23px;
  }

  .contacts-search-panel,
  .contacts-content {
    padding-right: 16px;
    padding-left: 16px;
  }

  .contacts-card .contacts-tools {
    grid-template-columns: minmax(0, 1fr) 74px;
  }

  .contact-item {
    align-items: flex-start;
  }

  .contact-actions {
    flex-direction: column;
    gap: 6px;
  }

  .app-shell {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    height: var(--app-height);
    overflow: hidden;
  }

  .chat-page {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
  }

  .me-page {
    padding: 14px;
  }

  .me-page-inner {
    max-width: none;
    gap: 12px;
  }

  .me-hero {
    align-items: flex-start;
    gap: 12px;
    padding: 18px;
    border-radius: 16px;
  }

  .me-avatar {
    width: 52px;
    height: 52px;
    font-size: 17px;
  }

  .me-hero h2 {
    font-size: 24px;
  }

  .me-hero p {
    white-space: normal;
  }

  .me-section {
    padding: 18px;
  }

  .main-tabbar {
    gap: 6px;
    padding: 7px 10px max(7px, env(safe-area-inset-bottom));
  }

  .main-tab {
    height: 48px;
    border-radius: 12px;
    font-size: 14px;
  }

  .rooms-pane,
  .chat-pane {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    transition: transform 180ms ease;
    will-change: transform;
  }

  .rooms-pane {
    z-index: 1;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    border-right: 0;
    transform: translateX(0);
  }

  .chat-pane {
    z-index: 2;
    display: flex;
    transform: translateX(100%);
  }

  body.route-lobby .rooms-pane {
    transform: translateX(0);
  }

  body.route-lobby .chat-pane {
    pointer-events: none;
    transform: translateX(100%);
  }

  body.route-chat .rooms-pane {
    pointer-events: none;
    transform: translateX(-24%);
  }

  body.route-chat .chat-pane {
    pointer-events: auto;
    transform: translateX(0);
  }

  .back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 0;
    overflow: hidden;
    color: var(--primary);
    border: 0;
    background: transparent;
  }

  .back-button svg {
    display: block;
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .chat-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 66px;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
    gap: 4px;
  }

  .chat-heading {
    margin-right: 0;
    padding-left: 2px;
  }

  .chat-header-actions {
    grid-column: 1 / -1;
    gap: 6px;
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    padding-top: 4px;
  }

  .chat-title {
    font-size: 18px;
  }

  .chat-subtitle {
    font-size: 12px;
  }

  .compact-button {
    height: 34px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 13px;
    white-space: nowrap;
  }

  .message-list {
    padding: 16px 10px;
  }

  .message-bubble {
    max-width: 76%;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 68px;
    gap: 8px;
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }

  .send-button {
    width: 68px;
  }

  .call-strip {
    top: 86px;
    right: 10px;
  }

  .call-tiles.video-grid {
    gap: 8px;
    padding: 76px 10px 108px;
  }

  .call-tiles.video-grid[data-grid-size="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .call-tiles.video-grid[data-grid-size="8"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .call-tiles.video-grid[data-grid-size="12"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .call-tiles.video-grid .call-tile {
    border-radius: 14px;
  }

  .call-tiles.video-grid .call-avatar {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    font-size: 20px;
  }

  .call-strip .call-tile {
    width: 96px;
    height: 128px;
    border-radius: 14px;
  }

  .call-controls {
    gap: 8px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .call-button {
    min-width: 74px;
    height: 46px;
    padding: 0 12px;
  }
}

/* Visual refresh */
:root {
  --bg: #f3f7fb;
  --panel: #ffffff;
  --panel-soft: #f6f9fc;
  --line: #dde7f1;
  --text: #132238;
  --muted: #66758b;
  --primary: #13877e;
  --primary-strong: #0a625d;
  --primary-soft: #e2f7f2;
  --accent: #3b82f6;
  --danger: #ef3f4a;
  --warning: #d2952c;
  --shadow: 0 18px 48px rgba(43, 59, 82, 0.12);
  --soft-shadow: 0 10px 30px rgba(43, 59, 82, 0.08);
}

body {
  background:
    linear-gradient(180deg, #f8fbfd 0%, #edf4f8 46%, #f7f9fc 100%),
    var(--bg);
}

button,
input,
textarea {
  letter-spacing: 0;
}

button {
  transition:
    transform 140ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

input,
textarea {
  border-color: #d8e3ef;
  background: #fbfdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

input:focus,
textarea:focus {
  border-color: rgba(19, 135, 126, 0.6);
  box-shadow:
    0 0 0 4px rgba(19, 135, 126, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.primary-button,
.danger-button,
.icon-button {
  box-shadow: 0 10px 22px rgba(19, 135, 126, 0.16);
}

.primary-button {
  background: linear-gradient(180deg, #18978c, var(--primary));
}

.primary-button:hover {
  background: linear-gradient(180deg, #12877d, var(--primary-strong));
  box-shadow: 0 12px 26px rgba(19, 135, 126, 0.2);
}

.ghost-button,
.back-button {
  color: #20314a;
  border-color: #dbe5f0;
  background: linear-gradient(180deg, #fff, #f8fbfd);
}

.ghost-button:hover,
.back-button:hover {
  border-color: rgba(19, 135, 126, 0.26);
  color: var(--primary-strong);
  background: #f8fffd;
}

.danger-button {
  background: linear-gradient(180deg, #ff555f, var(--danger));
  box-shadow: 0 12px 26px rgba(239, 63, 74, 0.18);
}

.auth-screen {
  background:
    linear-gradient(135deg, rgba(19, 135, 126, 0.08) 0%, rgba(59, 130, 246, 0.07) 42%, rgba(255, 255, 255, 0) 42.2%),
    linear-gradient(180deg, #f7fbfd, #eef5f8);
}

.auth-card,
.sheet-card,
.contacts-card,
.me-hero,
.me-section {
  border-color: rgba(208, 220, 234, 0.9);
  box-shadow: var(--soft-shadow);
}

.auth-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.brand-mark {
  color: #063d39;
  background: linear-gradient(145deg, #79ecd7, #42d4b8);
  box-shadow:
    inset 0 -12px 18px rgba(13, 94, 86, 0.12),
    0 12px 24px rgba(32, 201, 174, 0.2);
}

.app-shell {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(239, 246, 250, 0.96)),
    var(--bg);
}

.rooms-pane {
  border-right-color: rgba(216, 227, 239, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 251, 253, 0.96)),
    var(--panel);
}

.profile-name,
.chat-title,
.me-hero h2,
.me-section h3,
.room-name {
  color: #102033;
}

.profile-status,
.chat-subtitle,
.room-last,
.thread-meta,
.message-meta,
.me-hero p {
  color: #687891;
}

.home-tools {
  padding: 2px;
  border: 1px solid rgba(216, 227, 239, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.home-tools .search-input {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.home-tools .ghost-button {
  background: #fff;
}

.room-section {
  padding: 12px;
  border-color: rgba(216, 227, 239, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 28px rgba(43, 59, 82, 0.04);
}

.section-title,
.contacts-section-title {
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
}

.room-list {
  gap: 6px;
}

.room-item {
  min-height: 66px;
  border-color: transparent;
  border-radius: 16px;
  background: transparent;
}

.room-item:hover,
.room-item.active {
  border-color: rgba(19, 135, 126, 0.24);
  background: linear-gradient(180deg, #f3fffb, #eaf9f5);
  box-shadow: 0 10px 24px rgba(19, 135, 126, 0.08);
}

.room-item.not-joined {
  border-color: rgba(203, 213, 225, 0.72);
  background: rgba(248, 250, 252, 0.78);
}

.room-item.not-joined:hover {
  border-color: rgba(19, 135, 126, 0.22);
  background: linear-gradient(180deg, #fbfffe, #f2fbf8);
}

.thread-avatar {
  border-radius: 16px;
  background: #e7f7f3;
}

.thread-avatar.direct {
  background: linear-gradient(145deg, #7a8ba3, #52647b);
}

.room-pill {
  color: #0a625d;
  background: #dff6ef;
}

.chat-pane {
  background: #f7fafd;
}

.chat-header {
  border-bottom-color: rgba(216, 227, 239, 0.86);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

.chat-header-actions {
  padding: 3px;
  border: 1px solid rgba(216, 227, 239, 0.72);
  border-radius: 14px;
  background: rgba(248, 251, 253, 0.82);
}

.message-list {
  background:
    linear-gradient(180deg, rgba(247, 250, 253, 0.94), rgba(241, 247, 250, 0.98)),
    var(--panel-soft);
}

.message-bubble {
  border-color: rgba(216, 227, 239, 0.88);
  border-radius: 18px 18px 18px 8px;
  box-shadow: 0 8px 22px rgba(43, 59, 82, 0.07);
}

.message-row.mine .message-bubble {
  border-radius: 18px 18px 8px 18px;
  background: linear-gradient(180deg, #19968c, #0f7e75);
  box-shadow: 0 10px 24px rgba(19, 135, 126, 0.18);
}

.message-avatar {
  border-radius: 12px;
  background: linear-gradient(145deg, #7c8da5, #55677e);
}

.composer {
  border-top-color: rgba(216, 227, 239, 0.86);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.composer textarea {
  min-height: 46px;
  border-radius: 16px;
  background: #f8fbfd;
}

.send-button {
  border-radius: 14px;
}

.me-page {
  background:
    linear-gradient(180deg, #f8fbfd 0%, #edf5f8 100%),
    var(--panel-soft);
}

.me-page-inner {
  max-width: 760px;
  gap: 14px;
}

.me-hero {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(226, 247, 242, 0.96), rgba(255, 255, 255, 0.98) 52%, rgba(238, 246, 255, 0.95)),
    #fff;
}

.me-avatar {
  border-radius: 18px;
}

.me-hero h2 {
  font-size: 31px;
}

.me-card {
  gap: 14px;
}

.me-section {
  gap: 14px;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
}

.me-section label {
  margin-top: 2px;
  color: #586a82;
}

.me-section input {
  height: 48px;
  border-radius: 14px;
}

.me-section input[type="file"] {
  padding: 11px 12px;
}

.me-section input[type="file"]::file-selector-button,
.profile-form input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--primary-strong);
  background: #e4f7f2;
  font-weight: 900;
  cursor: pointer;
}

.me-section .full-button {
  height: 48px;
  border-radius: 14px;
  font-size: 16px;
}

.main-tabbar {
  gap: 10px;
  border-top-color: rgba(216, 227, 239, 0.86);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.main-tab {
  height: 50px;
  border-radius: 16px;
}

.main-tab.active {
  border-color: rgba(19, 135, 126, 0.2);
  background: linear-gradient(180deg, #e5fbf5, #d9f4ec);
  box-shadow: 0 10px 22px rgba(19, 135, 126, 0.11);
}

.main-tab-icon {
  border-radius: 9px;
  background: rgba(19, 135, 126, 0.12);
}

.members-sheet {
  background: rgba(20, 32, 48, 0.28);
  backdrop-filter: blur(8px);
}

.sheet-card {
  border-radius: 22px;
}

.contacts-card {
  border-radius: 22px;
}

.contacts-header {
  background:
    linear-gradient(135deg, rgba(226, 247, 242, 0.96), rgba(255, 255, 255, 0.98) 58%),
    #fff;
}

.contact-item,
.member-item {
  border-color: rgba(216, 227, 239, 0.82);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(18, 29, 44, 0.92);
  box-shadow: 0 18px 48px rgba(18, 29, 44, 0.2);
  backdrop-filter: blur(10px);
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(180deg, #f8fbfd 0%, #edf4f8 100%),
      var(--panel);
  }

  .rooms-pane {
    padding: 16px 14px 12px;
    background: linear-gradient(180deg, #fbfdff, #f3f8fb);
  }

  .home-tools {
    border-radius: 18px;
  }

  .room-section {
    border-radius: 18px;
  }

  .me-page {
    padding: 14px 14px 12px;
  }

  .me-page-inner {
    gap: 14px;
  }

  .me-hero {
    padding: 20px;
    border-radius: 20px;
  }

  .me-hero h2 {
    font-size: 25px;
  }

  .me-section {
    padding: 20px;
    border-radius: 20px;
  }

  .main-tabbar {
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  .main-tab {
    height: 48px;
    border-radius: 15px;
  }

  .chat-header {
    background: rgba(255, 255, 255, 0.9);
  }

  .chat-header-actions {
    border-radius: 12px;
  }

  .message-list {
    padding: 16px 12px;
  }
}

/* Profile page and tabbar refinement */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.rooms-pane {
  gap: 18px;
}

.rooms-pane > .home-tools:first-child {
  margin-top: 0;
}

.main-tabbar {
  display: flex;
  justify-content: center;
  gap: 34px;
  padding: 8px 18px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
}

.main-tab {
  display: grid;
  grid-template-columns: auto;
  grid-template-rows: 26px 18px;
  gap: 2px;
  width: 86px;
  height: 50px;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #718196;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}

.main-tab.active {
  color: var(--primary-strong);
  border: 0;
  background: transparent;
  box-shadow: none;
}

.main-tab-icon {
  width: 30px;
  height: 26px;
  border-radius: 999px;
  background: rgba(113, 129, 150, 0.12);
}

.main-tab.active .main-tab-icon {
  color: #063d39;
  background: linear-gradient(180deg, #d9faf2, #c8f3e9);
  box-shadow: 0 8px 18px rgba(19, 135, 126, 0.14);
}

.me-page {
  padding: 22px min(5vw, 56px);
}

.me-page-inner {
  max-width: 680px;
  gap: 16px;
}

.me-hero {
  align-items: center;
  gap: 20px;
  padding: 24px;
}

.me-avatar-editor {
  display: grid;
  flex: 0 0 auto;
  gap: 10px;
  justify-items: center;
}

.me-avatar {
  width: 82px;
  height: 82px;
  border-radius: 24px;
  font-size: 24px;
}

.avatar-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: rgba(226, 247, 242, 0.94);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition:
    background 160ms ease,
    box-shadow 160ms ease;
}

.avatar-upload-button:hover {
  background: #d5f5ec;
  box-shadow: 0 8px 18px rgba(19, 135, 126, 0.12);
}

.avatar-upload-hint {
  color: #7a8ba1;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.me-hero h2 {
  font-size: 28px;
}

.me-section {
  gap: 18px;
}

.profile-edit-row {
  display: grid;
  gap: 8px;
}

.profile-edit-row input {
  height: 50px;
  padding: 0 15px;
  font-size: 16px;
}

.me-section .full-button {
  margin-top: 2px;
}

@media (max-width: 760px) {
  .rooms-pane {
    padding-top: 14px;
  }

  .main-tabbar {
    justify-content: space-around;
    gap: 0;
    padding: 7px 26px max(7px, env(safe-area-inset-bottom));
  }

  .main-tab {
    width: 74px;
    height: 48px;
    border-radius: 13px;
  }

  .main-tab.active {
    background: transparent;
  }

  .me-page {
    padding: 14px 14px 10px;
  }

  .me-hero {
    align-items: center;
    gap: 16px;
    padding: 20px;
  }

  .me-avatar {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    font-size: 21px;
  }

  .avatar-upload-button {
    height: 32px;
    padding: 0 11px;
  }

  .me-hero h2 {
    font-size: 24px;
  }
}

/* Search bar and app tabbar polish */
.home-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.home-tools .search-input {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 46px;
  border: 1px solid rgba(205, 219, 233, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 8px 24px rgba(43, 59, 82, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.search-box:focus-within {
  border-color: rgba(19, 135, 126, 0.36);
  background: #fff;
  box-shadow:
    0 10px 26px rgba(19, 135, 126, 0.1),
    0 0 0 4px rgba(19, 135, 126, 0.08);
}

.search-icon {
  display: grid;
  width: 38px;
  height: 100%;
  flex: 0 0 38px;
  place-items: center;
  color: #8a98aa;
}

.search-icon svg,
.tool-button svg,
.main-tab-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-input {
  height: 44px;
  min-width: 0;
  padding: 0 12px 0 0;
  border: 0;
  border-radius: 16px;
  color: #26364d;
  background: transparent;
}

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

.tool-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(205, 219, 233, 0.95);
  border-radius: 15px;
  color: #31445d;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(43, 59, 82, 0.06);
  font-size: 15px;
  font-weight: 950;
}

.contact-request-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #ef3f4a;
  box-shadow: 0 6px 14px rgba(239, 63, 74, 0.26);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
}

.tool-button svg {
  width: 21px;
  height: 21px;
  stroke-width: 2.15;
}

.tool-button:hover {
  color: var(--primary-strong);
  border-color: rgba(19, 135, 126, 0.28);
  background: #f7fffc;
}

.add-tool {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, #18978c, #0f7e75);
  box-shadow: 0 10px 24px rgba(19, 135, 126, 0.22);
  font-size: 24px;
  line-height: 1;
}

.add-tool:hover {
  color: #fff;
  background: linear-gradient(180deg, #12877d, #0a625d);
}

.main-tabbar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 4px 28px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(214, 226, 238, 0.92);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 30px rgba(43, 59, 82, 0.05);
}

.main-tab {
  position: relative;
  display: grid;
  grid-template-rows: 28px 17px;
  gap: 1px;
  width: auto;
  height: 54px;
  place-items: center;
  border: 0;
  border-radius: 0;
  color: #7b8798;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 850;
}

.main-tab::before {
  content: "";
  position: absolute;
  top: -4px;
  width: 30px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
}

.main-tab.active {
  color: var(--primary-strong);
  background: transparent;
  box-shadow: none;
}

.main-tab.active::before {
  background: var(--primary);
}

.main-tab-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 0;
  background: transparent;
}

.main-tab.active .main-tab-icon {
  color: var(--primary-strong);
  background: transparent;
  box-shadow: none;
}

.main-tab-icon svg {
  width: 23px;
  height: 23px;
  stroke-width: 2.15;
}

.main-tab.active .main-tab-icon svg {
  fill: rgba(19, 135, 126, 0.14);
}

@media (max-width: 760px) {
  .rooms-pane {
    padding-top: 12px;
  }

  .home-tools {
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 7px;
  }

  .search-box {
    height: 46px;
    border-radius: 17px;
  }

  .tool-button {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .main-tabbar {
    padding-right: 34px;
    padding-left: 34px;
  }

  .main-tab {
    height: 52px;
  }
}

/* Latest layout tuning: move creation and inline profile editing */
.home-tools {
  grid-template-columns: minmax(0, 1fr) 42px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  margin: 0 2px 10px;
}

.section-title-row .section-title {
  margin-bottom: 0;
}

.section-add-tool {
  width: 34px;
  height: 34px;
  border-color: rgba(19, 135, 126, 0.18);
  border-radius: 999px;
  color: var(--primary-strong);
  background: linear-gradient(180deg, #effffb, #dff7f0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 8px 18px rgba(19, 135, 126, 0.1);
}

.section-add-tool svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.7;
}

.section-add-tool:hover {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, #1a9d91, #0f7e75);
  box-shadow: 0 10px 22px rgba(19, 135, 126, 0.18);
}

.me-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.me-hero-copy {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.me-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.me-name-stack {
  min-width: 0;
}

.me-title-row .section-title {
  margin-left: 0;
}

.me-hero h2 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-save-button {
  height: 34px;
  min-width: 62px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
}

.me-inline-profile-form {
  display: none;
  gap: 0;
  margin: 0;
}

.me-page.profile-editing .me-inline-profile-form {
  display: grid;
}

.me-page.profile-editing .me-hero h2 {
  display: none;
}

.me-inline-profile-form input:not(.visually-hidden) {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.84);
}

.avatar-upload-hint.visually-hidden {
  margin: 0;
}

.me-card {
  display: grid;
}

.me-card .me-section {
  margin: 0;
}

@media (max-width: 760px) {
  .home-tools {
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .section-add-tool {
    width: 32px;
    height: 32px;
  }

  .me-hero {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 16px;
    padding: 18px;
  }

  .me-avatar {
    width: 72px;
    height: 72px;
    border-radius: 21px;
    font-size: 22px;
  }

  .avatar-upload-button {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
  }

  .me-title-row {
    gap: 8px;
  }

  .profile-save-button {
    height: 32px;
    min-width: 56px;
    padding: 0 12px;
  }

  .me-inline-profile-form input:not(.visually-hidden) {
    height: 42px;
    font-size: 14px;
  }
}

/* Chat detail polish */
.chat-header {
  min-height: 72px;
  padding: 14px 18px;
}

.chat-heading {
  flex: 1 1 auto;
  margin-right: 0;
}

.chat-header .chat-header-actions {
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 8px;
}

.chat-header-actions .chat-icon-button {
  position: relative;
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border-radius: 14px;
  line-height: 1;
}

.chat-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-header-actions .chat-icon-button.ghost-button {
  color: #28405c;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 8px 18px rgba(43, 59, 82, 0.06);
}

.chat-header-actions .chat-icon-button.ghost-button:hover {
  color: var(--primary-strong);
  border-color: rgba(19, 135, 126, 0.28);
  background: #f2fffb;
}

.chat-header-actions .chat-icon-button.primary-button {
  color: #fff;
  border: 0;
  background: linear-gradient(180deg, #1a9d91, #0f7e75);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 12px 24px rgba(19, 135, 126, 0.2);
}

.chat-header-actions .chat-icon-button:disabled {
  cursor: not-allowed;
  color: #9aabbd;
  border-color: rgba(216, 227, 239, 0.8);
  background: rgba(248, 251, 253, 0.78);
  box-shadow: none;
}

.chat-header-actions .chat-icon-button.primary-button:disabled {
  color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(180deg, #9bd6cf, #72bdb5);
}

.chat-icon-button:focus-visible {
  outline: 3px solid rgba(19, 135, 126, 0.18);
  outline-offset: 3px;
}

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

.empty-chat {
  font-weight: 700;
  letter-spacing: 0;
}

@media (max-width: 760px) {
  .chat-header {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 70px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }

  .back-button {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 14px;
  }

  .back-button svg {
    width: 24px;
    height: 24px;
  }

  .chat-heading {
    min-width: 0;
    padding-left: 0;
  }

  .chat-title {
    font-size: 19px;
    line-height: 1.18;
  }

  .chat-subtitle {
    margin-top: 2px;
    font-size: 12px;
  }

  .chat-header .chat-header-actions {
    grid-column: auto;
    justify-content: flex-end;
    overflow: visible;
    padding-top: 0;
    gap: 6px;
  }

  .chat-header-actions .chat-icon-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    border-radius: 13px;
  }

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

  .message-list {
    padding: 14px 12px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 8px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  .send-button {
    width: 64px;
    border-radius: 16px;
  }
}

@media (max-width: 390px) {
  .chat-header {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    padding-right: 10px;
    padding-left: 10px;
  }

  .back-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

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

  .chat-header-actions .chat-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    border-radius: 12px;
  }
}

/* Contact request list scrolling */
.contacts-card .contacts-content {
  flex: 1 1 auto;
}

.contacts-section {
  min-height: 0;
}

.contacts-card #friendRequestList,
.contacts-card #sentFriendRequestList {
  max-height: min(280px, 36dvh);
  margin-right: -4px;
  padding: 2px 4px 2px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 132, 116, 0.34) transparent;
  -webkit-overflow-scrolling: touch;
}

.contacts-card #friendRequestList::-webkit-scrollbar,
.contacts-card #sentFriendRequestList::-webkit-scrollbar {
  width: 6px;
}

.contacts-card #friendRequestList::-webkit-scrollbar-thumb,
.contacts-card #sentFriendRequestList::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(20, 132, 116, 0.28);
}

.contacts-card #friendRequestList::-webkit-scrollbar-track,
.contacts-card #sentFriendRequestList::-webkit-scrollbar-track {
  background: transparent;
}

.contacts-card #friendRequestList .contact-item,
.contacts-card #sentFriendRequestList .contact-item {
  min-height: 70px;
  border-color: rgba(187, 214, 225, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 254, 253, 0.96)),
    #fff;
  box-shadow: 0 8px 22px rgba(43, 59, 82, 0.05);
}

.contacts-card #friendRequestList .contact-actions,
.contacts-card #sentFriendRequestList .contact-actions {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.contacts-card #friendRequestList .contact-actions .compact-button {
  min-width: 52px;
  height: 32px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: 13px;
}

.contact-status-pill.sent {
  color: #0f766e;
  border-color: rgba(20, 132, 116, 0.18);
  background: #e8fbf6;
}

@media (max-width: 760px) {
  .contacts-card #friendRequestList,
  .contacts-card #sentFriendRequestList {
    max-height: min(240px, 32dvh);
  }

  .contacts-card #friendRequestList .contact-item,
  .contacts-card #sentFriendRequestList .contact-item {
    align-items: center;
    min-height: 72px;
    padding: 10px;
  }

  .contacts-card #friendRequestList .contact-actions,
  .contacts-card #sentFriendRequestList .contact-actions {
    flex-direction: row;
  }
}

/* Emoji composer */
.composer {
  position: relative;
  grid-template-columns: 44px minmax(0, 1fr) 78px;
}

.emoji-button,
.voice-message-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  align-self: end;
  border-radius: 16px;
  color: #28405c;
  background: rgba(255, 255, 255, 0.86);
}

.emoji-button svg,
.voice-message-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.emoji-button:hover,
.emoji-button[aria-expanded="true"],
.voice-message-button:hover,
.voice-message-button.recording {
  color: var(--primary-strong);
  border-color: rgba(19, 135, 126, 0.28);
  background: #f2fffb;
  box-shadow: 0 10px 22px rgba(19, 135, 126, 0.1);
}

.voice-message-button.recording {
  width: 64px;
  min-width: 64px;
  color: #fff;
  background: linear-gradient(180deg, #ef4444, #dc2626);
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.2);
  animation: voicePulse 1s ease-in-out infinite;
}

.voice-message-button.recording svg {
  width: 17px;
  height: 17px;
}

.voice-message-button.recording::after {
  content: attr(data-duration);
  margin-left: 3px;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
}

.emoji-button:disabled,
.voice-message-button:disabled {
  cursor: not-allowed;
  color: #9aabbd;
  background: rgba(248, 251, 253, 0.74);
  box-shadow: none;
}

@keyframes voicePulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.94);
  }
}

.emoji-panel {
  position: absolute;
  right: 22px;
  bottom: calc(100% + 8px);
  left: 22px;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
  max-height: min(240px, 34dvh);
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(203, 213, 225, 0.86);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 132, 116, 0.32) transparent;
  -webkit-overflow-scrolling: touch;
}

.emoji-panel::-webkit-scrollbar {
  width: 6px;
}

.emoji-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(20, 132, 116, 0.28);
}

.emoji-panel::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-item {
  display: grid;
  width: 100%;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  transition:
    background-color 150ms ease,
    transform 150ms ease;
  touch-action: manipulation;
}

.emoji-item:hover,
.emoji-item:focus-visible {
  outline: none;
  background: rgba(223, 248, 243, 0.9);
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .composer {
    grid-template-columns: 42px minmax(0, 1fr) 64px;
    gap: 8px;
  }

  .emoji-button,
  .voice-message-button {
    width: 42px;
    height: 44px;
    border-radius: 15px;
  }

  .emoji-panel {
    right: 12px;
    left: 12px;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    max-height: min(232px, 34dvh);
    padding: 10px;
    border-radius: 18px;
  }

  .emoji-item {
    height: 36px;
    border-radius: 11px;
    font-size: 21px;
  }
}

/* Minimized call window */
.call-topbar {
  align-items: flex-start;
  gap: 12px;
}

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

.call-topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.call-mini-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 34px;
  width: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.call-mini-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call-mini-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.call-tiles.focused-video {
  background:
    radial-gradient(circle at 20% 12%, rgba(20, 184, 166, 0.18), transparent 30%),
    #050816;
}

.call-panel.minimized {
  inset: auto 18px calc(82px + env(safe-area-inset-bottom)) auto;
  width: min(184px, calc(100vw - 28px));
  height: 116px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
  cursor: grab;
  touch-action: none;
}

.call-panel.minimized,
.call-panel.minimized * {
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.call-panel.minimized video {
  pointer-events: none;
}

.call-panel.minimized.audio-minimized {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.2), transparent 34%),
    linear-gradient(135deg, #0f766e, #132238);
}

.call-panel.minimized.dragging {
  cursor: grabbing;
}

.call-panel.minimized .call-topbar,
.call-panel.minimized .call-controls,
.call-panel.minimized .call-label,
.call-panel.minimized .call-strip,
.call-panel.minimized .call-tiles.video-grid .call-tile:not(:first-child) {
  display: none;
}

.call-panel.minimized .call-tiles {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #050816;
}

.call-panel.minimized.video-minimized .call-tiles {
  display: block;
  padding: 0;
}

.call-panel.minimized .call-tile,
.call-panel.minimized .call-tiles.video-grid .call-tile,
.call-panel.minimized .call-tile.main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #050816;
}

.call-panel.minimized .call-tile video {
  object-fit: cover;
  background: #050816;
}

.call-panel.minimized.audio-minimized .call-tiles {
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
}

.call-panel.minimized.audio-minimized .call-tile,
.call-panel.minimized.audio-minimized .call-strip {
  display: none;
}

.call-panel.minimized.audio-minimized .call-tiles::before {
  content: "";
  width: 30px;
  height: 30px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3Zm6-3.5a6 6 0 0 1-12 0M12 16.5V21M8.5 21h7' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 14a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v5a3 3 0 0 0 3 3Zm6-3.5a6 6 0 0 1-12 0M12 16.5V21M8.5 21h7' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (max-width: 760px) {
  .call-panel.minimized {
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: min(168px, calc(100vw - 24px));
    height: 106px;
    border-radius: 17px;
  }

  .call-panel.minimized.audio-minimized {
    width: 64px;
    height: 64px;
  }
}

/* Huawei-like bottom tabbar */
.main-tabbar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 0;
  min-height: calc(72px + env(safe-area-inset-bottom));
  padding: 7px 34px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(220, 231, 240, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 253, 255, 0.96));
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.9),
    0 -12px 28px rgba(42, 59, 82, 0.05);
  backdrop-filter: blur(18px);
}

.main-tab {
  position: relative;
  display: grid;
  grid-template-rows: 34px 18px;
  gap: 2px;
  width: auto;
  height: 58px;
  place-items: center;
  border: 0;
  border-radius: 0;
  color: #8a98aa;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.main-tab::before {
  display: none;
}

.main-tab-icon {
  display: grid;
  width: 46px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  color: inherit;
  background: transparent;
  box-shadow: none;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.main-tab-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-tab.active {
  color: #08746c;
  background: transparent;
  box-shadow: none;
}

.main-tab.active .main-tab-icon {
  color: #075e55;
  background: linear-gradient(180deg, #dffaf3, #cbf1e8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 8px 20px rgba(15, 118, 110, 0.13);
}

.main-tab.active .main-tab-icon svg {
  fill: none;
}

.main-tab:not(.active):hover {
  color: #607086;
}

.main-tab:not(.active):hover .main-tab-icon {
  background: rgba(226, 235, 244, 0.72);
}

.main-tab:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.14);
  outline-offset: -6px;
  border-radius: 18px;
}

@media (max-width: 760px) {
  .main-tabbar {
    min-height: calc(70px + env(safe-area-inset-bottom));
    padding-right: 38px;
    padding-left: 38px;
  }

  .main-tab {
    height: 56px;
  }
}

/* Chat action sheets: fixed header/footer with internal scrolling */
#membersSheet .sheet-card,
#groupSheet .sheet-card,
#groupManageSheet .sheet-card,
#messageSearchSheet .sheet-card {
  display: flex;
  flex-direction: column;
  max-height: min(680px, calc(var(--app-height) - 32px));
  min-height: 0;
  overflow: hidden;
}

#membersSheet .sheet-header,
#groupSheet .sheet-header,
#groupManageSheet .sheet-header,
#messageSearchSheet .sheet-header,
#groupSheet .sheet-footer,
#membersSheet #addMemberButton {
  flex: 0 0 auto;
}

#membersSheet #memberList,
#membersSheet #addMemberList,
#groupSheet #groupMemberList,
#groupManageSheet #groupManageMembers,
#messageSearchSheet #messageSearchResults {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 132, 116, 0.32) transparent;
  -webkit-overflow-scrolling: touch;
}

#membersSheet #memberList::-webkit-scrollbar,
#membersSheet #addMemberList::-webkit-scrollbar,
#groupSheet #groupMemberList::-webkit-scrollbar,
#groupManageSheet #groupManageMembers::-webkit-scrollbar,
#messageSearchSheet #messageSearchResults::-webkit-scrollbar {
  width: 6px;
}

#membersSheet #memberList::-webkit-scrollbar-thumb,
#membersSheet #addMemberList::-webkit-scrollbar-thumb,
#groupSheet #groupMemberList::-webkit-scrollbar-thumb,
#groupManageSheet #groupManageMembers::-webkit-scrollbar-thumb,
#messageSearchSheet #messageSearchResults::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(20, 132, 116, 0.28);
}

#membersSheet #memberList {
  flex: 1 1 190px;
}

#membersSheet .add-member-panel {
  display: flex;
  flex: 1 1 240px;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

#membersSheet .add-member-panel.hidden {
  display: none;
}

/* Compact chat detail view */
@media (max-width: 760px) {
  body.page-chat.route-chat .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  body.page-chat.route-chat .main-tabbar {
    display: none;
  }

  body.page-chat.route-chat .chat-header {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 54px;
    padding: max(5px, env(safe-area-inset-top)) 8px 5px;
    gap: 5px;
  }

  body.page-chat.route-chat .back-button {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 11px;
  }

  body.page-chat.route-chat .back-button svg {
    width: 22px;
    height: 22px;
  }

  body.page-chat.route-chat .chat-title {
    font-size: 18px;
    line-height: 1.12;
  }

  body.page-chat.route-chat .chat-subtitle {
    margin-top: 0;
    font-size: 11px;
    line-height: 1.15;
  }

  body.page-chat.route-chat .chat-header .chat-header-actions {
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.page-chat.route-chat .chat-header-actions .chat-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  body.page-chat.route-chat .chat-icon-button svg {
    width: 17px;
    height: 17px;
  }
}

#membersSheet #addMemberList,
#groupSheet #groupMemberList,
#groupManageSheet #groupManageMembers,
#messageSearchSheet #messageSearchResults {
  flex: 1 1 auto;
}

#groupSheet .group-form {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

#groupManageSheet .profile-form,
#messageSearchSheet .contacts-tools {
  flex: 0 0 auto;
}

#groupManageSheet > .sheet-card > .section-title {
  flex: 0 0 auto;
  margin: 0 18px 8px;
}

@media (max-width: 760px) {
  #membersSheet .sheet-card,
  #groupSheet .sheet-card,
  #groupManageSheet .sheet-card,
  #messageSearchSheet .sheet-card {
    max-height: calc(var(--app-height) - 28px);
  }
}

/* Final chat controls guardrails */
.chat-header .chat-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-header-actions .chat-icon-button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  overflow: hidden;
}

.chat-header-actions .chat-icon-button svg {
  display: block;
}

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

.composer {
  position: relative;
  grid-template-columns: 44px minmax(0, 1fr) 64px 78px;
}

.emoji-button,
.voice-message-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  place-items: center;
}

@media (max-width: 760px) {
  .composer {
    grid-template-columns: 42px minmax(0, 1fr) 64px 64px;
  }

  .emoji-button,
  .voice-message-button {
    width: 42px;
    min-width: 42px;
  }
}

/* Message body only: no reactions or read labels */
.message-row {
  align-items: flex-start;
}

.message-system-row {
  width: 100%;
}

.message-content {
  display: grid;
  max-width: min(620px, 72%);
  gap: 5px;
  justify-items: start;
}

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

.message-bubble {
  max-width: 100%;
}

.voice-message {
  display: inline-flex;
  width: auto;
  min-width: 96px;
  height: 30px;
  min-height: 30px;
  align-items: center;
  overflow: hidden;
}

.voice-play-button {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.voice-play-icon {
  position: relative;
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}

.message-row.mine .voice-play-icon {
  background: rgba(255, 255, 255, 0.2);
}

.voice-play-icon::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
}

.voice-play-button.playing .voice-play-icon::before {
  width: 9px;
  height: 10px;
  margin-left: 0;
  border: 0;
  border-right: 3px solid currentColor;
  border-left: 3px solid currentColor;
}

.voice-play-label {
  line-height: 1;
  white-space: nowrap;
}

.voice-duration {
  display: none;
}

.message-bubble .message-meta,
.message-bubble .message-reactions,
.message-bubble .message-read-status,
.message-bubble .message-quote {
  display: none;
}

.message-meta,
.message-quote {
  max-width: 100%;
}

.message-reactions,
.message-read-status {
  display: none !important;
}

.message-row > .message-avatar {
  align-self: flex-start;
  margin-top: 20px;
}

@media (max-width: 760px) {
  .message-content {
    max-width: min(76%, 310px);
  }

  .voice-message {
    min-width: 92px;
  }
}

/* Members sheet cleanup */
#membersSheet .sheet-card {
  width: min(390px, calc(100vw - 28px));
  max-height: min(560px, calc(var(--app-height) - 30px));
  border-radius: 22px;
}

#membersSheet .members-block-title {
  flex: 0 0 auto;
  padding: 13px 18px 2px;
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
}

#membersSheet #memberList {
  flex: 0 0 auto;
  max-height: 164px;
  padding: 10px 14px 14px;
}

#membersSheet #memberList .member-item {
  min-height: 56px;
  border: 1px solid rgba(216, 227, 239, 0.88);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(43, 59, 82, 0.05);
}

#membersSheet .add-member-panel {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(216, 227, 239, 0.92);
  background: linear-gradient(180deg, #f8fbfd, #f3f8fb);
}

#membersSheet .add-member-panel.hidden {
  display: none;
}

#membersSheet .group-member-head {
  margin: 0;
}

#membersSheet #addMemberList {
  flex: 1 1 auto;
  min-height: 88px;
  max-height: 220px;
  padding: 0;
}

#membersSheet .compact-empty {
  display: flex;
  min-height: 48px;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
}

#membersSheet #addMemberButton {
  flex: 0 0 auto;
  margin-top: auto;
}

#membersSheet #addMemberButton:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
}

/* Final mobile chat detail compaction */
@media (max-width: 760px) {
  body.page-chat.route-chat .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  body.page-chat.route-chat .main-tabbar {
    display: none;
  }

  body.page-chat.route-chat .chat-pane {
    min-height: 0;
  }

  body.page-chat.route-chat .chat-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  body.page-chat.route-chat .chat-header {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    min-height: 50px;
    padding: max(4px, env(safe-area-inset-top)) 8px 4px;
    gap: 5px;
  }

  body.page-chat.route-chat .back-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    flex-basis: 32px;
    border-radius: 11px;
  }

  body.page-chat.route-chat .back-button svg {
    width: 20px;
    height: 20px;
  }

  body.page-chat.route-chat .chat-heading {
    min-width: 0;
  }

  body.page-chat.route-chat .chat-title {
    font-size: 18px;
    line-height: 1.05;
  }

  body.page-chat.route-chat .chat-subtitle {
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.05;
  }

  body.page-chat.route-chat .chat-header .chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.page-chat.route-chat .chat-header-actions .chat-icon-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  body.page-chat.route-chat .chat-icon-button svg {
    width: 17px;
    height: 17px;
  }
}

/* Final recalled-message notice sizing */
.message-system-row {
  width: auto;
  max-width: calc(100% - 72px);
  min-height: 16px;
  align-items: center;
  margin: 4px auto 8px;
  color: #8fa0b3;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.message-system-row::before,
.message-system-row::after {
  width: 16px;
  margin: auto 6px;
}

.message-time-row {
  margin: 8px auto 10px;
}

.thread-avatar.has-image,
.message-avatar.has-image,
.call-avatar.has-image,
.me-avatar.has-image {
  overflow: hidden;
  color: transparent;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: cover !important;
}
