:root {
  color-scheme: light;
  --window-bg: #f5f7fb;
  --sidebar-bg: #eef3f8;
  --chat-bg: #f8fafc;
  --surface: #ffffff;
  --line: #dce4ef;
  --line-strong: #d5dfec;
  --text: #172033;
  --title: #111827;
  --muted: #64748b;
  --status-bg: #edf2f7;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-pressed: #1e40af;
  --disabled: #cbd5e1;
  --connected-bg: #e8f7ef;
  --connected-text: #146c43;
  --error-bg: #fee2e2;
  --error-border: #fecaca;
  --error-text: #991b1b;
  --selected-bg: #dbeafe;
  --selected-text: #1d4ed8;
  --hover-bg: #e7eef8;
  --mine-bg: #7c96cf;
  --other-bg: #eef2f7;
  --system-bg: #f1f5f9;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background: var(--window-bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: #ffffff;
  padding: 8px 18px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

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

button:active:not(:disabled) {
  background: var(--primary-pressed);
}

button:disabled {
  background: var(--disabled);
  color: #f8fafc;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #334155;
}

.secondary-button:hover:not(:disabled) {
  background: #f1f5f9;
}

.secondary-button:active:not(:disabled) {
  background: #e2e8f0;
}

input {
  min-width: 0;
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

input:focus {
  border-color: #60a5fa;
  outline: 0;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-window {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid transparent;
  background: var(--window-bg);
  padding: 24px;
}

.app-title {
  margin: 0 0 18px;
  color: var(--title);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row span {
  color: #334155;
}

.advanced-panel {
  margin-top: 2px;
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
}

.login-actions .secondary-button {
  flex: 0 1 auto;
}

.status-pill {
  min-height: 34px;
  border-radius: 10px;
  background: var(--status-bg);
  color: #475569;
  margin-top: 14px;
  padding: 7px 10px;
  line-height: 20px;
}

.status-pill.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.mini-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.friend-tools-list {
  display: grid;
  gap: 5px;
  max-height: 112px;
  overflow: auto;
}

.friend-tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 5px 7px;
  font-size: 12px;
}

.friend-request-actions {
  display: flex;
  gap: 4px;
}

.friend-tool-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.compact-button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.online-section {
  overflow: auto;
}

.session-tools {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.58);
  padding: 8px;
}

.session-tools summary {
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.session-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 8px;
}

.session-list {
  display: grid;
  gap: 5px;
  max-height: 150px;
  overflow: auto;
  margin-top: 7px;
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  background: var(--surface);
  padding: 6px;
}

.session-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.session-meta strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-form {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.password-form input {
  min-height: 34px;
  border-radius: 8px;
  font-size: 11px;
}

.mini-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 10px;
  line-height: 16px;
}

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

.qt-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 5px;
}

.qt-list.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

.list-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  padding: 7px 9px;
  text-align: left;
}

.list-item:hover {
  background: var(--hover-bg);
}

.list-item.active {
  background: var(--selected-bg);
  color: var(--selected-text);
}

.user-chat-button {
  min-width: 0;
}

.video-call-button {
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 5px 9px;
  font-size: 12px;
}

.video-call-button:hover:not(:disabled) {
  background: #dbeafe;
}

.video-call-button:disabled {
  border-color: var(--line);
  background: #f1f5f9;
  color: #94a3b8;
}

.block-user-button {
  min-height: 34px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #b91c1c;
  padding: 5px 9px;
  font-size: 12px;
}

.block-user-button:hover:not(:disabled) {
  background: #ffe4e6;
}

.wide-button {
  width: 100%;
}

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

.history-search-results {
  display: grid;
  max-height: 132px;
  gap: 6px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.88);
  margin-top: 8px;
  padding: 8px;
}

.history-search-result {
  border-bottom: 1px solid var(--line);
  padding: 5px 4px;
  color: var(--title);
  font-size: 13px;
}

.history-search-result:last-child {
  border-bottom: 0;
}

.message-row {
  display: flex;
  width: 100%;
  background: transparent;
}

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

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

.message-row.system,
.message-row.error {
  justify-content: center;
}

.message-row.mine .message-bubble {
  background: #9bcdf0;
  color: #000000;
}

.message-row.other .message-bubble {
  background: #ffffff;
  color: var(--text);
}

.message-row.system .message-bubble {
  background: var(--system-bg);
  color: var(--muted);
}

.message-row.error .message-bubble {
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.message-sender {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
}

.message-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.45;
}

.message-image {
  display: block;
  width: auto;
  max-width: min(360px, 100%);
  max-height: 320px;
  border-radius: 10px;
  object-fit: contain;
}

.file-download {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
}

.file-download:disabled {
  cursor: wait;
  opacity: 0.72;
}

.message-time {
  margin-top: 4px;
  color: inherit;
  font-size: 11px;
  line-height: 14px;
  opacity: 0.78;
  text-align: right;
}

.message-row.other .message-time,
.message-row.system .message-time {
  color: var(--muted);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.16);
  padding: 20px;
  z-index: 20;
}

.room-dialog {
  width: min(340px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--window-bg);
  padding: 18px;
  box-shadow: 0 18px 48px rgba(23, 32, 51, 0.16);
}

.room-dialog h2 {
  margin: 0 0 14px;
  color: var(--title);
  font-size: 18px;
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.danger-button {
  background: #dc2626;
}

.danger-button:hover:not(:disabled) {
  background: #b91c1c;
}

.danger-button:active:not(:disabled) {
  background: #991b1b;
}

.call-backdrop {
  background: rgba(15, 23, 42, 0.58);
  z-index: 30;
}

.call-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: #111827;
  color: #f8fafc;
  padding: 20px;
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.48);
}

.call-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.call-kicker {
  color: #93c5fd;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.call-dialog h2 {
  margin: 4px 0 0;
  color: #ffffff;
  font-size: 22px;
}

.call-peer {
  max-width: 44%;
  overflow: hidden;
  color: #cbd5e1;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-video-stage {
  position: relative;
  min-height: 300px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 16px;
  background: #020617;
  margin-top: 18px;
}

.remote-video {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  object-fit: contain;
}

.remote-video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  z-index: 0;
  place-items: center;
  color: #64748b;
}

.local-video {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  width: min(28%, 220px);
  aspect-ratio: 4 / 3;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  background: #0f172a;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.call-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: #cbd5e1;
  line-height: 24px;
}

.call-status.error {
  color: #fca5a5;
}

.call-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.call-dialog .secondary-button {
  border-color: #475569;
  background: #1e293b;
  color: #f8fafc;
}

.call-dialog .secondary-button:hover:not(:disabled) {
  background: #334155;
}

.active-call-actions {
  flex-wrap: wrap;
}

.message-reply {
  margin: 2px 0 7px;
  padding: 6px 8px;
  border-left: 3px solid currentColor;
  border-radius: 4px;
  background: rgb(255 255 255 / 12%);
  font-size: 0.82rem;
  opacity: 0.85;
}

.message-text.recalled {
  font-style: italic;
  opacity: 0.72;
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.message-actions button {
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.75rem;
  text-decoration: underline;
  opacity: 0.75;
  cursor: pointer;
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    grid-template-rows: auto auto auto auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .qt-list {
    min-height: 96px;
    max-height: 160px;
  }

  .chat-panel {
    min-height: 620px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .login-window {
    padding: 18px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .login-actions,
  .dialog-actions {
    flex-direction: column;
  }

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

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

  .call-dialog {
    padding: 16px;
  }

  .call-heading,
  .call-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .call-peer {
    max-width: 100%;
  }

  .call-video-stage {
    min-height: 220px;
  }

  .local-video {
    right: 10px;
    bottom: 10px;
    width: 34%;
  }
}

/* WeChat-inspired desktop shell: rail, conversations, active chat. */
.app-shell {
  display: grid;
  grid-template-columns: 64px 300px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-width: 780px;
  background: #f5f5f5;
}

.app-rail {
  position: relative;
  z-index: 12;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  background: #2e2e2e;
  padding: 16px 0 14px;
  color: #b9b9b9;
}

.rail-brand,
.rail-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.rail-brand {
  background: #4e9dde;
  color: #ffffff;
}

.rail-navigation {
  display: grid;
  width: 100%;
  gap: 8px;
  margin-top: 24px;
}

.rail-nav-item {
  display: grid;
  width: 100%;
  height: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  place-items: center;
  color: #9c9c9c;
  padding: 0;
  font-size: 15px;
}

.rail-nav-item:hover,
.rail-nav-item.active {
  background: #383838;
  color: #4e9dde;
}

.account-menu {
  position: relative;
  margin-top: auto;
}

.account-menu > summary,
.conversation-add-menu > summary,
.history-search-menu > summary {
  display: grid;
  list-style: none;
  place-items: center;
  cursor: pointer;
  user-select: none;
}

.account-menu > summary::-webkit-details-marker,
.conversation-add-menu > summary::-webkit-details-marker,
.history-search-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu > summary {
  position: relative;
  width: 42px;
  height: 42px;
}

.rail-avatar {
  background: #d8dee8;
  color: #243247;
  font-size: 11px;
}

.connection-status {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  min-height: 11px;
  overflow: hidden;
  border: 2px solid #2e2e2e;
  border-radius: 50%;
  background: #94a3b8;
  padding: 0;
  color: transparent;
  font-size: 0;
  line-height: 0;
}

.connection-status.connected {
  background: #4e9dde;
}

.connection-status.error {
  background: #fa5151;
}

.account-popover,
.conversation-add-popover,
.history-search-popover {
  position: absolute;
  z-index: 30;
  border: 1px solid #dedede;
  border-radius: 8px;
  background: #ffffff;
  color: #222222;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}

.account-popover {
  bottom: 0;
  left: 50px;
  width: 320px;
  max-height: min(560px, calc(100vh - 28px));
  overflow: auto;
  padding: 16px;
}

.account-popover h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.conversation-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #dedede;
  background: #e9e9e9;
}

.conversation-toolbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  padding: 14px 12px 10px;
}

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

.friend-search-row input {
  min-height: 34px;
  border: 0;
  border-radius: 6px 0 0 6px;
  background: #dcdcdc;
  padding: 7px 10px;
  font-size: 13px;
}

.search-friend-button {
  min-height: 34px;
  border: 0;
  border-radius: 0 6px 6px 0;
  background: #dcdcdc;
  padding: 0 9px;
  color: #575757;
  font-size: 12px;
}

.conversation-add-menu > summary {
  width: 36px;
  height: 34px;
  border-radius: 6px;
  background: #dcdcdc;
  color: #444444;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.conversation-add-popover {
  top: 40px;
  right: 0;
  width: 150px;
  overflow: hidden;
  padding: 5px;
}

.menu-action {
  width: 100%;
  min-height: 36px;
  border-radius: 5px;
  background: transparent;
  padding: 7px 10px;
  color: #222222;
  text-align: left;
}

.menu-action:hover:not(:disabled) {
  background: #f1f1f1;
}

.search-results {
  flex: 0 0 auto;
  max-height: 180px;
  margin: 0 12px 8px;
}

.conversation-section {
  display: flex;
  min-height: 0;
  flex: 0 0 auto;
  flex-direction: column;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.conversation-section.recent-section,
.conversation-section.online-section,
.conversation-section.rooms-section {
  flex: 1 1 auto;
}

.conversation-section-title {
  margin: 0;
  padding: 9px 12px 6px;
  color: #777777;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conversation-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-button {
  min-height: 28px;
  background: transparent;
  padding: 2px 12px;
  color: #777777;
  font-size: 11px;
}

.text-button:hover:not(:disabled) {
  background: transparent;
  color: #222222;
}

.conversation-sidebar .qt-list {
  flex: 1 1 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.conversation-sidebar .list-item {
  min-height: 54px;
  overflow: hidden;
  border-radius: 0;
  padding: 9px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-sidebar .list-item:hover {
  background: #dedede;
}

.conversation-sidebar .list-item.active {
  background: #c9c9c9;
  color: #222222;
}

.conversation-sidebar .conversation-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  text-align: left;
}

.conversation-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #4e9dde;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.conversation-avatar.room {
  background: #5b8def;
}

.conversation-copy,
.conversation-meta {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.conversation-copy {
  gap: 4px;
}

.conversation-name,
.conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-name {
  color: #222222;
  font-size: 15px;
  font-weight: 500;
}

.conversation-preview,
.conversation-time {
  color: #999999;
  font-size: 12px;
}

.conversation-meta {
  align-items: flex-end;
  gap: 6px;
}

.unread-badge {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: #fa5151;
  color: #ffffff;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
}

.conversation-sidebar .user-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 5px;
}

.conversation-sidebar .pending-friend-row {
  border: 1px solid #f59e0b;
  border-radius: 9px;
  background: #fffbeb;
  padding: 3px;
}

.conversation-sidebar .pending-request-button {
  min-height: 30px;
  border: 1px solid #d97706;
  border-radius: 8px;
  background: #f59e0b;
  color: #ffffff;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.conversation-sidebar .pending-request-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.friend-nav-badge {
  display: inline-flex;
  min-width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  margin-left: 3px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  line-height: 16px;
}

.conversation-sidebar .user-list-row .video-call-button,
.conversation-sidebar .user-list-row .block-user-button {
  min-height: 30px;
  padding: 4px 7px;
  font-size: 10px;
}

.maintenance-tools {
  flex: 0 0 auto;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 7px 12px 9px;
  color: #666666;
  font-size: 11px;
}

.maintenance-tools > summary {
  cursor: pointer;
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  gap: 0;
  background: #f5f5f5;
  padding: 0;
}

.chat-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e1e1e1;
  padding: 0 20px;
}

.chat-title {
  min-height: auto;
  margin: 0;
  background: transparent;
  color: var(--title);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
}

.history-search-menu > summary {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: #666666;
  font-size: 16px;
}

.history-search-menu > summary:hover {
  background: #e8e8e8;
}

.history-search-popover {
  top: 48px;
  right: 12px;
  width: min(560px, calc(100vw - 410px));
  padding: 10px;
}

.message-scroll {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #f5f5f5;
  padding: 18px 24px;
}

.message-bubble {
  width: fit-content;
  max-width: min(560px, 70%);
  border-radius: 6px;
  padding: 9px 12px;
  overflow-wrap: anywhere;
}

.message-input-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  border-top: 1px solid #e1e1e1;
  background: #ffffff;
  padding: 9px 14px;
}

.message-input-row input,
.message-input-row button {
  min-height: 40px;
}

.message-input-row #messageInput {
  border: 0;
  border-radius: 6px;
  background: #f7f7f7;
  padding: 8px 11px;
}

.attachment-button {
  display: grid;
  width: 38px;
  height: 40px;
  place-items: center;
  border-radius: 6px;
  color: #555555;
  cursor: pointer;
  font-size: 19px;
}

.attachment-button:hover {
  background: #f1f1f1;
}

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

.send-file-button {
  min-height: 40px;
  padding: 7px 12px;
}

.message-input-row #sendButton {
  min-height: 40px;
  border-radius: 6px;
  background: #4e9dde;
  padding: 7px 18px;
}

.message-input-row #sendButton:hover:not(:disabled) {
  background: #3f87c5;
}

/* Crystal blue UI: this final layer intentionally replaces the legacy dense
   dark/green shell above while retaining all existing DOM contracts. */
:root {
  color-scheme: light;
  --crystal-sky: #dff3ff;
  --crystal-blue: #76b8e8;
  --crystal-blue-deep: #347cb9;
  --crystal-ink: #17324d;
  --crystal-muted: #67809a;
  --crystal-line: rgba(255, 255, 255, 0.74);
  --crystal-panel: rgba(255, 255, 255, 0.54);
  --crystal-panel-strong: rgba(255, 255, 255, 0.74);
  --crystal-shadow: 0 24px 70px rgba(47, 113, 164, 0.16), 0 4px 16px rgba(52, 118, 170, 0.08);
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, 0.98) 0 10%, transparent 31%),
    radial-gradient(circle at 88% 78%, rgba(139, 205, 246, 0.36) 0 8%, transparent 35%),
    linear-gradient(132deg, #effaff 0%, #dff2ff 47%, #c8e9fb 100%);
  color: var(--crystal-ink);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.005em;
}

button,
input {
  font-family: inherit;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  background: linear-gradient(145deg, #68afe4, #468bca);
  box-shadow: 0 8px 18px rgba(44, 124, 184, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-weight: 650;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, background 180ms ease-out;
}

button:hover:not(:disabled) {
  background: linear-gradient(145deg, #81c2ed, #4b91d1);
  box-shadow: 0 12px 24px rgba(44, 124, 184, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  background: #4085c5;
  transform: scale(0.975);
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
.attachment-button:focus-visible {
  outline: 3px solid rgba(56, 143, 208, 0.36);
  outline-offset: 3px;
}

.secondary-button,
.text-button,
.menu-action {
  border-color: rgba(104, 163, 205, 0.16);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 5px 14px rgba(48, 111, 159, 0.07);
  color: var(--crystal-ink);
}

.secondary-button:hover:not(:disabled),
.text-button:hover:not(:disabled),
.menu-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.88);
  color: var(--crystal-blue-deep);
}

input {
  border-color: rgba(93, 156, 201, 0.17);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: inset 0 1px 2px rgba(34, 101, 149, 0.04), 0 3px 10px rgba(44, 116, 164, 0.04);
  color: var(--crystal-ink);
}

input:focus {
  border-color: rgba(72, 153, 215, 0.72);
  box-shadow: 0 0 0 4px rgba(116, 184, 232, 0.2);
}

.login-view {
  padding: 40px;
}

.login-window {
  width: min(480px, calc(100vw - 40px));
  border: 1px solid var(--crystal-line);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(239, 250, 255, 0.48));
  box-shadow: var(--crystal-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(28px) saturate(145%);
  padding: 38px;
}

.app-title {
  margin-bottom: 28px;
  color: var(--crystal-ink);
  font-size: 30px;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.form-row {
  grid-template-columns: 106px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.form-row span,
.status-pill,
.mini-status {
  color: var(--crystal-muted);
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(12px);
}

.app-shell {
  grid-template-columns: 78px 342px minmax(0, 1fr);
  width: min(1540px, calc(100vw - 48px));
  height: min(930px, calc(100vh - 48px));
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--crystal-line);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.38);
  box-shadow: var(--crystal-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(28px) saturate(135%);
  margin: 24px auto;
}

.app-rail {
  border-right: 1px solid rgba(255, 255, 255, 0.46);
  background: linear-gradient(180deg, rgba(44, 104, 153, 0.9), rgba(50, 126, 181, 0.72));
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.16);
  color: rgba(239, 249, 255, 0.72);
  padding: 20px 0 18px;
}

.rail-brand,
.rail-avatar {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(11, 57, 94, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.rail-brand {
  background: linear-gradient(145deg, #dff5ff, #84c8ee);
  color: #275f8f;
}

.rail-avatar {
  background: rgba(255, 255, 255, 0.83);
  color: #2f6a99;
}

.rail-navigation {
  gap: 12px;
  margin-top: 30px;
}

.rail-nav-item {
  width: 52px;
  height: 52px;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 17px;
  background: transparent;
  color: rgba(236, 248, 255, 0.72);
  font-size: 17px;
}

.rail-nav-item:hover,
.rail-nav-item.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.21), 0 7px 16px rgba(8, 54, 94, 0.12);
  color: #ffffff;
}

.connection-status {
  border-color: rgba(50, 119, 170, 0.82);
  background: #9cc4df;
}

.connection-status.connected {
  background: #9ed7f2;
  box-shadow: 0 0 0 3px rgba(176, 229, 255, 0.18);
}

.conversation-sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(241, 250, 255, 0.36));
}

.conversation-toolbar {
  gap: 12px;
  padding: 22px 18px 14px;
}

.friend-search-row input,
.search-friend-button,
.conversation-add-menu > summary {
  min-height: 40px;
  border: 1px solid rgba(115, 174, 214, 0.12);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.friend-search-row input {
  border-radius: 13px 0 0 13px;
}

.search-friend-button {
  border-radius: 0 13px 13px 0;
  color: var(--crystal-blue-deep);
}

.conversation-add-menu > summary {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: var(--crystal-blue-deep);
}

.conversation-section {
  border-top-color: rgba(117, 174, 213, 0.11);
}

.conversation-section-title {
  padding: 16px 18px 8px;
  color: #6e8ba3;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
}

.conversation-sidebar .list-item {
  margin: 2px 10px;
  min-height: 68px;
  border: 1px solid transparent;
  border-radius: 17px;
  color: var(--crystal-ink);
  padding: 10px 12px;
}

.conversation-sidebar .list-item:hover {
  border-color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.56);
}

.conversation-sidebar .list-item.active {
  border-color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(222, 243, 255, 0.68));
  box-shadow: 0 8px 20px rgba(54, 132, 181, 0.12), inset 0 1px 0 #ffffff;
  color: var(--crystal-ink);
}

.conversation-avatar {
  border-radius: 15px;
  background: linear-gradient(145deg, #bfe8ff, #6faee1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54);
}

.conversation-avatar.room {
  background: linear-gradient(145deg, #d6e8ff, #91b9e8);
}

.conversation-name {
  color: var(--crystal-ink);
  font-weight: 680;
}

.conversation-preview,
.conversation-time {
  color: var(--crystal-muted);
}

.unread-badge {
  background: linear-gradient(145deg, #f49aa9, #df6179);
  box-shadow: 0 3px 8px rgba(203, 75, 100, 0.2);
}

.chat-panel {
  grid-template-rows: 78px minmax(0, 1fr) auto auto;
  background: rgba(248, 253, 255, 0.31);
}

.chat-header {
  border-bottom-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.28);
  padding: 0 30px;
}

.chat-title {
  color: var(--crystal-ink);
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.history-search-menu > summary {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--crystal-blue-deep);
}

.history-search-menu > summary:hover {
  background: rgba(255, 255, 255, 0.63);
}

.message-scroll {
  gap: 16px;
  background: transparent;
  padding: 30px clamp(24px, 5vw, 72px);
}

.message-bubble {
  max-width: min(620px, 72%);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 8px 20px rgba(49, 123, 170, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  color: var(--crystal-ink);
  padding: 13px 16px;
}

.message-row.mine .message-bubble {
  border-color: rgba(222, 245, 255, 0.7);
  background: linear-gradient(145deg, rgba(133, 194, 232, 0.92), rgba(84, 157, 209, 0.88));
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(49, 133, 193, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

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

.message-input-row {
  min-height: 82px;
  border-top-color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(20px) saturate(140%);
  padding: 15px 24px;
}

.message-input-row #messageInput {
  border: 1px solid rgba(112, 174, 216, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  padding: 10px 14px;
}

.attachment-button {
  border-radius: 15px;
  color: var(--crystal-blue-deep);
}

.attachment-button:hover {
  background: rgba(255, 255, 255, 0.6);
}

.message-input-row #sendButton {
  border-radius: 15px;
  background: linear-gradient(145deg, #71b8e9, #4388c8);
  padding-inline: 22px;
}

.message-input-row #sendButton:hover:not(:disabled) {
  background: linear-gradient(145deg, #8ac8ef, #4e94d2);
}

.action-status {
  border-top: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.24);
  color: var(--crystal-muted);
  padding: 6px 24px 10px;
}

.account-popover,
.conversation-add-popover,
.history-search-popover,
.room-dialog,
.call-dialog {
  border-color: var(--crystal-line);
  border-radius: 22px;
  background: rgba(248, 253, 255, 0.78);
  box-shadow: var(--crystal-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(28px) saturate(145%);
  color: var(--crystal-ink);
  transform-origin: top right;
  animation: crystal-pop-in 220ms ease-out both;
}

.room-dialog,
.call-dialog {
  transform-origin: center;
}

.dialog-backdrop {
  background: rgba(35, 92, 132, 0.22);
  backdrop-filter: blur(7px);
}

.is-gesture-lift {
  box-shadow: 0 18px 34px rgba(31, 103, 154, 0.22) !important;
  transform: translateY(-3px) scale(1.018) !important;
}

.cursor-aura,
.cursor-core {
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(calc(var(--pointer-x, -100px) - 50%), calc(var(--pointer-y, -100px) - 50%), 0);
  transition: width 180ms ease-out, height 180ms ease-out, opacity 180ms ease-out, background 180ms ease-out;
}

.cursor-aura {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(144, 211, 249, 0.34), rgba(105, 182, 232, 0.08) 66%, transparent 68%);
  box-shadow: 0 0 24px rgba(92, 181, 235, 0.38);
}

.cursor-core {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(75, 159, 216, 0.64), 0 0 15px rgba(71, 163, 219, 0.76);
}

.has-custom-cursor .cursor-aura,
.has-custom-cursor .cursor-core {
  opacity: 1;
}

.has-custom-cursor button,
.has-custom-cursor summary,
.has-custom-cursor .attachment-button,
.has-custom-cursor .list-item {
  cursor: none;
}

.is-dragging .cursor-aura {
  width: 66px;
  height: 66px;
  background: radial-gradient(circle, rgba(181, 231, 255, 0.52), rgba(94, 185, 237, 0.1) 68%, transparent 70%);
  box-shadow: 0 0 34px rgba(96, 191, 241, 0.5);
}

.is-pointer-pressed .cursor-core {
  transform: translate3d(calc(var(--pointer-x, -100px) - 50%), calc(var(--pointer-y, -100px) - 50%), 0) scale(0.72);
}

@keyframes crystal-pop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell {
    grid-template-columns: 68px 282px minmax(0, 1fr);
    width: calc(100vw - 28px);
    height: calc(100vh - 28px);
    margin: 14px auto;
  }
  .history-search-popover { width: min(460px, calc(100vw - 370px)); }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell {
    grid-template-columns: 58px minmax(200px, 38vw) minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    min-height: 600px;
    border: 0;
    border-radius: 0;
    margin: 0;
  }
  .app-rail { padding-top: 14px; }
  .rail-nav-item { width: 46px; height: 46px; min-height: 46px; }
  .conversation-toolbar { padding: 14px 10px 10px; }
  .conversation-sidebar .list-item { margin-inline: 6px; }
  .chat-header { padding-inline: 16px; }
  .message-scroll { padding: 22px 16px; }
  .message-bubble { max-width: 86%; }
  .message-input-row { padding: 10px 12px; }
  .history-search-popover { width: min(440px, calc(100vw - 80px)); }
}

@media (max-width: 540px) {
  .login-view { padding: 20px; }
  .login-window { padding: 32px 28px; }
  .login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .login-actions #advancedButton { grid-column: 1 / -1; }
  .login-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
  .cursor-aura,
  .cursor-core { display: none; }
}

.action-status {
  min-height: 28px;
  border-radius: 0;
  background: #ffffff;
  margin-top: 0;
  padding: 4px 14px 7px;
  font-size: 11px;
  line-height: 17px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 56px 260px minmax(464px, 1fr);
  }

  .app-rail {
    padding-top: 12px;
  }

  .history-search-popover {
    width: min(460px, calc(100vw - 340px));
  }
}

@media (max-width: 779px) {
  .app-shell {
    grid-template-columns: 52px minmax(190px, 34vw) minmax(0, 1fr);
    min-width: 0;
  }

  .conversation-toolbar {
    grid-template-columns: minmax(0, 1fr) 32px;
    padding-inline: 8px;
  }

  .search-friend-button {
    padding-inline: 6px;
  }

  .message-scroll {
    padding: 14px;
  }

  .message-input-row {
    grid-template-columns: 32px minmax(0, 1fr) 38px 54px;
    gap: 5px;
    padding-inline: 8px;
  }

  .send-file-button {
    width: 38px;
    overflow: hidden;
    padding: 0;
    font-size: 0;
  }

  .send-file-button::before {
    content: "↑";
    font-size: 16px;
  }

  .message-input-row #sendButton {
    padding-inline: 9px;
  }
}

/* Phone experience: a touch-first list/detail flow instead of compressed columns. */
.mobile-back-button {
  display: none;
}

@media (max-width: 779px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    background: #eef7fd;
  }

  .app-shell {
    position: relative;
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #f8fbfd;
    box-shadow: none;
  }

  .conversation-sidebar,
  .chat-panel {
    position: absolute;
    inset: 0 0 calc(64px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    min-width: 0;
    height: auto;
    border: 0;
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
                opacity 180ms ease-out;
  }

  .conversation-sidebar {
    z-index: 2;
    display: flex;
    background:
      linear-gradient(180deg, rgba(231, 246, 255, 0.98), rgba(248, 252, 255, 0.98));
    padding-top: env(safe-area-inset-top, 0px);
    transform: translateX(0);
  }

  .chat-panel {
    z-index: 3;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-top: env(safe-area-inset-top, 0px);
    background: #f3f7fa;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
  }

  .app-shell.mobile-chat-open .conversation-sidebar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-24%);
  }

  .app-shell.mobile-chat-open .chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .app-rail {
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    display: grid;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: 1fr auto;
    border: 0;
    border-top: 1px solid rgba(126, 170, 201, 0.22);
    border-radius: 0;
    background: rgba(248, 252, 255, 0.9);
    padding: 7px max(14px, env(safe-area-inset-right, 0px))
      env(safe-area-inset-bottom, 0px)
      max(14px, env(safe-area-inset-left, 0px));
    backdrop-filter: blur(22px) saturate(160%);
    box-shadow: 0 -8px 30px rgba(38, 103, 151, 0.08);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .rail-brand {
    display: none;
  }

  .rail-navigation {
    display: grid;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 4px;
    margin: 0;
  }

  .app-shell.mobile-chat-open .app-rail {
    pointer-events: none;
    transform: translateY(100%);
  }

  .app-shell.mobile-chat-open .chat-panel {
    bottom: 0;
  }

  .rail-nav-item {
    width: auto;
    min-width: 0;
    height: 50px;
    min-height: 50px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    box-shadow: none;
    color: #66839a;
    font-size: 0;
  }

  .rail-nav-item::after {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    font-weight: 650;
  }

  .rail-nav-item[data-sidebar-target="recentSection"]::after { content: "Chats"; }
  .rail-nav-item[data-sidebar-target="friendsSection"]::after { content: "Friends"; }
  .rail-nav-item[data-sidebar-target="roomsSection"]::after { content: "Rooms"; }

  .rail-nav-item:hover:not(:disabled),
  .rail-nav-item.active {
    border: 0;
    background: rgba(93, 172, 226, 0.13);
    box-shadow: none;
    color: #287fbd;
    transform: none;
  }

  .friend-nav-badge {
    position: absolute;
    margin: -20px 0 0 12px;
  }

  .session-tools {
    align-self: center;
    border: 0;
    background: transparent;
    padding: 0;
  }

  .session-tools > summary {
    width: 44px;
    height: 44px;
  }

  .connection-status {
    display: none;
  }

  .account-popover {
    position: fixed;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    width: auto;
    max-height: min(70dvh, 580px);
    overflow: auto;
    border-radius: 22px;
  }

  .conversation-toolbar {
    min-height: 68px;
    gap: 10px;
    padding: 12px 14px 8px;
  }

  .friend-search-row input {
    min-height: 46px;
    border-radius: 15px;
    font-size: 16px;
  }

  .search-friend-button {
    min-height: 44px;
  }

  .conversation-add-menu > summary {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .conversation-add-popover {
    right: 0;
    width: min(220px, calc(100vw - 28px));
  }

  .conversation-section {
    padding: 4px 10px 12px;
  }

  .conversation-section-title {
    padding-inline: 8px;
    font-size: 24px;
    letter-spacing: -0.02em;
  }

  .conversation-sidebar .qt-list {
    min-height: 0;
    max-height: initial;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.58);
    padding: 5px;
  }

  .conversation-sidebar .conversation-item {
    width: 100%;
    min-height: 72px;
    margin: 2px 0;
    border-radius: 14px;
    padding: 8px 10px;
  }

  .conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 15px;
  }

  .conversation-name {
    font-size: 16px;
    font-weight: 650;
  }

  .chat-header {
    min-height: 58px;
    gap: 8px;
    border-bottom: 1px solid rgba(126, 170, 201, 0.18);
    background: rgba(248, 252, 255, 0.88);
    padding: 6px 10px;
    backdrop-filter: blur(20px) saturate(150%);
  }

  .mobile-back-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #287fbd;
    padding: 4px 4px 4px 0;
    font-size: 14px;
  }

  .mobile-back-button span:first-child {
    font-size: 31px;
    font-weight: 350;
    line-height: 24px;
  }

  .mobile-back-button:hover:not(:disabled) {
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  .chat-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    font-size: 16px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-search-menu > summary {
    width: 44px;
    height: 44px;
  }

  .history-search-popover {
    position: fixed;
    top: calc(58px + env(safe-area-inset-top, 0px));
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 55dvh;
    overflow: auto;
    border-radius: 18px;
  }

  .history-search-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .history-search-more-button {
    grid-column: 1 / -1;
  }

  .message-scroll {
    gap: 8px;
    padding: 14px 12px 18px;
    scroll-padding-bottom: 16px;
  }

  .message-bubble {
    max-width: 82%;
    border-radius: 17px;
    padding: 9px 12px;
  }

  .message-image {
    max-width: min(72vw, 320px);
    max-height: 42vh;
  }

  .message-input-row {
    grid-template-columns: 44px minmax(0, 1fr) 46px;
    min-height: 64px;
    gap: 6px;
    border-top: 1px solid rgba(126, 170, 201, 0.18);
    background: rgba(250, 253, 255, 0.94);
    padding: 8px max(8px, env(safe-area-inset-right, 0px))
      max(8px, env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px));
    backdrop-filter: blur(20px) saturate(150%);
  }

  .attachment-button {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .message-input-row #messageInput {
    min-height: 44px;
    border-radius: 16px;
    background: #edf4f8;
    padding-inline: 13px;
    font-size: 16px;
  }

  .send-file-button {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .message-input-row #sendButton {
    width: 46px;
    min-height: 44px;
    overflow: hidden;
    border-radius: 14px;
    padding: 0;
    font-size: 0;
  }

  .message-input-row #sendButton::after {
    content: "\2191";
    font-size: 22px;
    line-height: 1;
  }

  .action-status {
    display: none;
  }

  .call-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 24px;
    padding: 14px;
  }

  .call-video-stage {
    min-height: 220px;
    aspect-ratio: 3 / 4;
  }

  .call-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@media (max-width: 779px) and (prefers-reduced-motion: reduce) {
  .conversation-sidebar,
  .chat-panel {
    transition: opacity 140ms ease-out;
    transform: none !important;
  }

  .app-shell.mobile-chat-open .conversation-sidebar,
  .chat-panel {
    visibility: hidden;
  }

  .app-shell.mobile-chat-open .chat-panel {
    visibility: visible;
  }
}
