:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #7d8b99;
  --line: #d8e2eb;
  --accent: #229ed9;
  --accent-strong: #168acd;
  --accent-soft: #e8f5fd;
  --danger: #d93025;
  --bubble: #ffffff;
  --mine: #e4f7d2;
  --chat-bg: #dfeaf2;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  height: 100%;
}

html,
body {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  min-height: 100dvh;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.auth-view {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: var(--chat-bg);
}

.auth-panel {
  width: min(430px, 100%);
  background: var(--panel);
  border: 0;
  border-radius: 10px;
  padding: 28px;
  box-shadow: 0 18px 58px rgba(23, 33, 43, 0.18);
}

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

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

h1,
h2,
p {
  margin: 0;
}

.brand-block h1,
.sidebar h1,
.chat-header h2 {
  line-height: 1.1;
}

.brand-block p,
.eyebrow,
.section-title,
.message-time,
.empty-state {
  color: var(--muted);
}

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

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #edf6fc;
  margin-bottom: 18px;
}

.auth-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 10px 12px;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12);
}

.auth-form,
.composer {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 158, 217, 0.18);
}

.primary-action,
.secondary-action,
.send-button,
.danger-action {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  padding: 12px 14px;
}

.primary-action:hover,
.secondary-action:hover,
.send-button:hover {
  background: var(--accent-strong);
}

.secondary-action {
  width: 100%;
  background: #4f8fba;
}

.danger-action {
  width: 100%;
  background: #b42318;
}

.danger-action:hover {
  background: #7a271a;
}

.error-line {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

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

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  flex-direction: column;
  gap: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 0;
  overflow: hidden;
}

.sidebar-header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-header {
  min-height: 64px;
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
}

.sidebar-header .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.sidebar h1 {
  color: #fff;
  font-size: 22px;
}

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

.settings-back-button {
  display: none;
}

.admin-menu-button {
  font-size: 13px;
  font-weight: 900;
}

.search-box {
  gap: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box span {
  display: none;
}

.search-box input {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: #f1f5f8;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.archive-toggle {
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid #edf2f6;
  background: #fff;
  color: var(--accent);
  padding: 0 14px;
  text-align: left;
  font-weight: 800;
}

.archive-toggle:hover {
  background: var(--accent-soft);
}

.settings-section,
.admin-panel {
  display: none;
}

.messenger-view.settings-open .chat-nav-section,
.messenger-view.admin-open .chat-nav-section,
.messenger-view.settings-open .chat-search,
.messenger-view.admin-open .chat-search,
.messenger-view.settings-open #openSettingsButton,
.messenger-view.settings-open #openAdminMenuButton,
.messenger-view.admin-open #openSettingsButton,
.messenger-view.admin-open #openAdminMenuButton {
  display: none;
}

.messenger-view.settings-open .settings-section {
  display: grid;
}

.messenger-view.admin-open .admin-panel:not([hidden]) {
  display: grid;
}

.messenger-view.settings-open .sidebar,
.messenger-view.admin-open .sidebar {
  overflow-y: auto;
}

.messenger-view.settings-open .settings-back-button,
.messenger-view.admin-open .settings-back-button {
  display: grid;
}

.eyebrow,
.section-title {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-title {
  margin: 8px 14px 6px;
  color: #8a98a8;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(34, 158, 217, 0.08);
  color: var(--accent);
  font-size: 18px;
}

.icon-button:hover {
  background: rgba(34, 158, 217, 0.14);
  color: var(--accent);
}

.sidebar-header .icon-button {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidebar-header .icon-button:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

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

.chat-back-button {
  display: none;
}

.conversation-list,
.user-list,
.invite-list {
  display: grid;
  gap: 0;
}

.sidebar-section.chat-nav-section {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conversation-button,
.user-button,
.invite-chip {
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #edf2f6;
  border-radius: 0;
  background: #fff;
  padding: 10px 14px;
}

.conversation-button:hover,
.user-button:hover,
.conversation-button.active {
  background: #f5f9fc;
}

.conversation-button.active {
  background: var(--accent-soft);
}

.conversation-button.saved .list-avatar {
  background: linear-gradient(135deg, #229ed9, #54a9eb);
  font-size: 18px;
}

.conversation-title,
.user-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 780;
}

.conversation-title,
.user-title {
  font-size: 15px;
}

.conversation-title > span:first-child,
.user-title > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-main {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.conversation-copy {
  display: grid;
  min-width: 0;
}

.list-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #54a9eb;
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.online-avatar::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #35c759;
}

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

.conversation-flags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.conversation-time {
  color: var(--muted);
  font-size: 11px;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #4fae4e;
  color: #fff;
  padding: 0 6px;
  font-size: 12px;
}

.conversation-preview,
.user-meta {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-preview {
  color: var(--accent);
  font-weight: 750;
}

.admin-panel {
  margin-top: auto;
  gap: 18px;
}

.settings-section {
  gap: 10px;
}

.sidebar > .settings-section,
.sidebar > .admin-panel {
  display: none;
}

.messenger-view.settings-open .sidebar > .settings-section {
  display: grid;
}

.messenger-view.admin-open .sidebar > .admin-panel:not([hidden]) {
  display: grid;
}

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

.pin-settings {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.profile-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 10px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
}

.avatar-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 750;
}

.admin-block,
.group-form {
  display: grid;
  gap: 10px;
}

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

.admin-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-status-card {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.admin-status-card span {
  color: var(--muted);
  font-size: 12px;
}

.admin-status-card strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.admin-user-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.admin-user-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.admin-user-row strong {
  color: var(--ink);
  font-size: 14px;
}

.admin-user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-user-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
  color: var(--ink);
  font-weight: 750;
}

.admin-user-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.push-device-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.push-device-row div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.push-device-row span,
.push-device-row code {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.push-device-row strong {
  color: var(--ink);
  font-size: 14px;
}

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

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

.audit-row div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.audit-row strong {
  color: var(--ink);
  font-size: 13px;
}

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

.audit-row p {
  margin: 0;
}

.secondary-action:disabled,
.danger-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.connect-block {
  display: grid;
  gap: 10px;
}

.connect-qr {
  width: min(190px, 100%);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.connect-url {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 9px;
  color: var(--ink);
  font-size: 12px;
}

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

.member-option {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  font-weight: 650;
}

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

.panel-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.settings-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.invite-chip {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.invite-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.invite-chip {
  display: grid;
  gap: 4px;
}

.invite-chip span {
  color: var(--muted);
  font-size: 12px;
}

.invite-chip.muted {
  color: var(--muted);
  background: #f8fafc;
}

.chat-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
  background: var(--chat-bg);
}

.chat-header {
  min-height: 64px;
  border-bottom: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  backdrop-filter: none;
}

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

.chat-header h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 18px;
}

.chat-header .eyebrow {
  color: rgba(255, 255, 255, 0.75);
}

.chat-header .icon-button {
  background: transparent;
  color: #fff;
}

.chat-header .icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.typing-indicator {
  min-height: 16px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.online {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
}

.message-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--chat-bg);
  padding: 18px min(7vw, 72px);
}

.empty-state {
  margin: auto;
  max-width: 360px;
  text-align: center;
  line-height: 1.45;
}

.message {
  display: grid;
  max-width: min(560px, 74%);
  gap: 2px;
  align-self: flex-start;
}

.message.mine {
  align-self: flex-end;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 4px;
  font-size: 11px;
  color: var(--muted);
}

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

.message-menu-trigger {
  width: 28px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.message-menu-trigger:hover {
  background: rgba(34, 158, 217, 0.1);
  color: var(--accent);
}

.message-bubble {
  border-radius: 16px;
  background: var(--bubble);
  padding: 8px 11px;
  overflow-wrap: anywhere;
  line-height: 1.4;
  box-shadow: 0 1px 1px rgba(23, 33, 43, 0.08);
}

.message-focus .message-bubble {
  outline: 3px solid rgba(34, 158, 217, 0.28);
}

.message:not(.mine) .message-bubble {
  border-bottom-left-radius: 4px;
}

.message.mine .message-bubble {
  border-bottom-right-radius: 4px;
}

.reply-quote {
  width: 100%;
  display: grid;
  gap: 3px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(34, 158, 217, 0.08);
  color: var(--ink);
  margin-bottom: 8px;
  padding: 7px 9px;
  text-align: left;
}

.reply-quote span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-actions {
  display: flex;
  gap: 6px;
  padding-inline: 4px;
}

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

.message-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
}

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

.attachment {
  display: grid;
  gap: 6px;
}

.attachment img,
.attachment video {
  max-width: 100%;
  max-height: 360px;
  border-radius: 12px;
  background: #111827;
}

.image-open {
  border: 0;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  text-align: left;
}

.image-open img {
  display: block;
}

.video-open {
  position: relative;
  border: 0;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  background: #111827;
}

.video-open video {
  display: block;
}

.video-open span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 34px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.attachment audio {
  width: min(360px, 100%);
}

.attachment-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.attachment-meta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment a,
.attachment-meta a {
  color: var(--accent-strong);
  font-weight: 750;
  text-decoration: none;
}

.voice-attachment,
.file-attachment {
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: min(310px, 72vw);
}

.voice-icon,
.file-icon,
.attachment-preview-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.voice-player {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.voice-player strong {
  color: var(--ink);
  font-size: 13px;
}

.voice-bars,
.voice-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.voice-bars i,
.voice-wave i {
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.voice-bars i:nth-child(1),
.voice-wave i:nth-child(1) { height: 10px; }
.voice-bars i:nth-child(2),
.voice-wave i:nth-child(2) { height: 18px; }
.voice-bars i:nth-child(3),
.voice-wave i:nth-child(3) { height: 13px; }
.voice-bars i:nth-child(4),
.voice-wave i:nth-child(4) { height: 22px; }
.voice-bars i:nth-child(5),
.voice-wave i:nth-child(5) { height: 15px; }
.voice-bars i:nth-child(6),
.voice-wave i:nth-child(6) { height: 19px; }
.voice-bars i:nth-child(7) { height: 11px; }

.voice-wave i {
  animation: wave-pulse 0.9s ease-in-out infinite alternate;
}

.voice-wave i:nth-child(2) { animation-delay: 0.08s; }
.voice-wave i:nth-child(3) { animation-delay: 0.16s; }
.voice-wave i:nth-child(4) { animation-delay: 0.24s; }
.voice-wave i:nth-child(5) { animation-delay: 0.32s; }
.voice-wave i:nth-child(6) { animation-delay: 0.4s; }

@keyframes wave-pulse {
  from { transform: scaleY(0.55); opacity: 0.65; }
  to { transform: scaleY(1.1); opacity: 1; }
}

.voice-player audio {
  width: min(280px, 100%);
}

.file-attachment .attachment-meta,
.voice-attachment .attachment-meta {
  grid-column: 2;
  flex-wrap: wrap;
}

.composer {
  grid-template-columns: 42px 42px minmax(0, 1fr) 44px;
  align-items: end;
  gap: 8px;
  border-top: 0;
  background: var(--chat-bg);
  padding: 10px 14px;
}

.attachment-preview,
.composer-status {
  grid-column: 1 / -1;
}

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

.attachment-preview-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  padding: 7px;
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.08);
}

.attachment-preview-thumb {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #edf6fc;
}

.attachment-preview-thumb img,
.attachment-preview-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-preview-item div:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.attachment-preview-item strong,
.attachment-preview-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-item strong {
  font-size: 13px;
}

.attachment-preview-item span {
  color: var(--muted);
  font-size: 12px;
}

.attachment-preview-item button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(217, 48, 37, 0.1);
  color: var(--danger);
  font-size: 20px;
}

.composer-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.voice-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(34, 158, 217, 0.18);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 800;
}

.voice-record-info {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(217, 48, 37, 0.1);
}

.voice-status button {
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 7px 10px;
  font-weight: 800;
}

.voice-status.locked {
  border-color: rgba(34, 158, 217, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 158, 217, 0.12);
}

.reply-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
}

.reply-panel div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.reply-panel span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer textarea {
  min-height: 44px;
  max-height: 150px;
  border: 0;
  border-radius: 22px;
  padding: 12px 16px;
  resize: none;
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.1);
}

.composer-disabled {
  opacity: 0.72;
}

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
}

.composer .icon-button {
  background: transparent;
  color: #6b7f91;
}

.composer .icon-button:hover {
  background: rgba(255, 255, 255, 0.52);
  color: var(--accent);
}

.pin-lock {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}

.pin-lock-panel {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.pin-lock-panel .brand-block {
  margin-bottom: 4px;
}

.pin-lock-panel input {
  text-align: center;
  letter-spacing: 0;
}

.action-sheet,
.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.action-sheet {
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(15, 23, 42, 0.42);
}

.action-sheet-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
  justify-self: center;
  border-radius: 14px 14px 8px 8px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.action-sheet-panel button {
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--ink);
  font-weight: 800;
}

.action-sheet-panel button:hover {
  background: var(--accent-soft);
}

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

.attachment-menu-panel button {
  text-align: left;
  padding-inline: 16px;
}

.chat-info-panel {
  width: min(460px, 100%);
  max-height: min(680px, calc(100dvh - 32px));
  display: grid;
  gap: 14px;
  justify-self: center;
  align-self: end;
  overflow: auto;
  border-radius: 14px 14px 8px 8px;
  background: #fff;
  padding: 14px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.chat-info-panel header,
.chat-info-summary,
.chat-member-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-info-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chat-info-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

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

.chat-info-summary,
.chat-member-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
}

.chat-info-summary div,
.chat-member-row div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.chat-info-summary span,
.chat-member-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-info-summary .list-avatar,
.chat-member-row .list-avatar {
  flex: 0 0 48px;
  color: #fff;
  font-size: 13px;
}

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

.chat-media-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.chat-media-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #edf6fc;
  padding: 0;
}

.chat-media-thumb img,
.chat-media-thumb video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.chat-media-thumb span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.media-viewer {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(2, 6, 23, 0.94);
}

.media-viewer-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: #fff;
}

.media-viewer-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-viewer-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-viewer-actions .icon-button {
  color: #fff;
  text-decoration: none;
}

.media-viewer-stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
}

.media-viewer img,
.media-viewer video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  min-height: 0;
  padding: 0 10px;
}

.media-nav-button {
  width: 44px;
  height: 68px;
  border: 0;
  border-radius: 999px;
  justify-self: center;
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
  font-size: 34px;
}

.media-nav-button:disabled {
  opacity: 0.28;
}

.media-viewer-meta {
  min-height: 44px;
  padding: 8px 16px 14px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  text-align: center;
}

.recording {
  border-color: #fca5a5;
  color: #b42318;
  background: #fef2f2;
}

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

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

  .sidebar {
    height: 100dvh;
    border-right: 0;
    border-bottom: 0;
    padding: 0;
  }

  .messenger-view:not(.chat-open) .chat-pane {
    display: none;
  }

  .messenger-view.chat-open .sidebar {
    display: none;
  }

  .chat-pane {
    height: 100dvh;
  }

  .chat-header {
    min-height: 64px;
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .chat-back-button {
    display: grid;
  }

  .chat-header h2 {
    font-size: 18px;
  }

  .status-pill {
    margin-left: auto;
    padding: 5px 8px;
    font-size: 11px;
  }

  .message-list {
    gap: 7px;
    padding: 14px 10px;
  }

  .message {
    max-width: 88%;
  }

  .message-meta {
    font-size: 11px;
  }

  .message-bubble {
    border-radius: 16px;
    padding: 10px 12px;
  }

  .message.mine .message-bubble {
    border-bottom-right-radius: 6px;
  }

  .message:not(.mine) .message-bubble {
    border-bottom-left-radius: 6px;
  }

  .message-actions {
    flex-wrap: wrap;
  }

  .chat-media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .media-viewer-stage {
    grid-template-columns: 1fr;
  }

  .media-nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }

  #prevMediaButton {
    left: 8px;
  }

  #nextMediaButton {
    right: 8px;
  }

  .media-viewer img,
  .media-viewer video {
    padding: 0;
  }

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

  .composer textarea {
    min-height: 44px;
    border-radius: 22px;
    padding: 10px 12px;
  }

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

  .send-button {
    width: 44px;
    height: 44px;
  }

  .auth-view {
    padding: 14px;
  }

  .auth-panel {
    padding: 20px;
  }

  .admin-status-grid {
    grid-template-columns: 1fr;
  }
}

/* Telegram-inspired interface polish. */
.messenger-view {
  grid-template-columns: minmax(318px, 390px) minmax(0, 1fr);
  background: var(--chat-bg);
}

.sidebar {
  border-right: 1px solid #d9e5ef;
  background: #fff;
}

.sidebar-header {
  min-height: 58px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f6;
  background: #fff;
  color: var(--ink);
}

.sidebar-header .eyebrow {
  display: none;
}

.sidebar h1 {
  color: var(--ink);
  font-size: 21px;
  letter-spacing: 0;
}

.sidebar-header .icon-button {
  background: transparent;
  color: #698193;
}

.sidebar-header .icon-button:hover {
  background: #edf6fc;
  color: var(--accent);
}

.search-box {
  position: relative;
  padding: 8px 10px;
  border-bottom: 1px solid #edf2f6;
}

.search-box::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid #8ca0af;
  border-radius: 50%;
  transform: translateY(-54%);
  opacity: 0.82;
}

.search-box::after {
  content: "";
  position: absolute;
  left: 36px;
  top: calc(50% + 6px);
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: #8ca0af;
  transform: rotate(45deg);
  opacity: 0.82;
}

.search-box input {
  min-height: 38px;
  border: 0;
  border-radius: 19px;
  background: #edf2f6;
  padding: 8px 14px 8px 40px;
}

.sidebar-section.chat-nav-section > .section-title {
  display: none;
}

.conversation-button {
  min-height: 72px;
  padding: 9px 12px;
  transition: background 0.15s ease;
}

.conversation-button:hover {
  background: #f3f8fc;
}

.conversation-button.active {
  background: #e7f4fc;
}

.conversation-main {
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
}

.list-avatar {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #63c0f4, #229ed9);
  font-size: 14px;
  box-shadow: inset 0 -14px 24px rgba(0, 0, 0, 0.08);
}

.conversation-title,
.user-title {
  font-size: 16px;
  font-weight: 760;
}

.conversation-preview,
.user-meta {
  margin-top: 4px;
  color: #667987;
  font-size: 14px;
}

.conversation-time {
  color: #8b9aa6;
  font-size: 12px;
  font-weight: 650;
}

.unread-badge {
  min-width: 23px;
  height: 23px;
  background: #4ecc5e;
  font-size: 12px;
  font-weight: 800;
}

.chat-pane {
  background: var(--chat-bg);
}

.chat-header {
  min-height: 58px;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #d6e2ec;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  backdrop-filter: blur(14px);
}

.chat-header > div {
  flex: 1 1 auto;
}

.chat-header-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, #63c0f4, #229ed9);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

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

.chat-header h2 {
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
}

.chat-header .eyebrow {
  margin-bottom: 1px;
  color: #6d8090;
  font-size: 12px;
  font-weight: 650;
  text-transform: none;
}

.typing-indicator {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.chat-header .icon-button {
  background: transparent;
  color: #6b7f91;
}

.chat-header .icon-button:hover {
  background: #edf6fc;
  color: var(--accent);
}

.status-pill {
  margin-left: 0;
  border: 1px solid #d8e5ef;
  background: #f6fafc;
  color: #6b7f91;
}

.message-list {
  gap: 5px;
  padding: 18px min(8vw, 96px);
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 12px 12px, rgba(255, 255, 255, 0.32) 0 1px, transparent 1px),
    radial-gradient(circle at 38px 34px, rgba(34, 158, 217, 0.09) 0 1px, transparent 1px);
  background-size: 52px 52px;
}

.message {
  max-width: min(620px, 72%);
}

.message-meta {
  gap: 5px;
  padding: 0 5px;
  color: rgba(82, 101, 116, 0.74);
  font-size: 11px;
}

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

.message-meta strong {
  color: #229ed9;
  font-size: 12px;
}

.message-time {
  color: rgba(82, 101, 116, 0.72);
  font-size: 11px;
}

.message-time.status-text {
  color: #49a05a;
  font-weight: 850;
  letter-spacing: -1px;
}

.message-menu-trigger {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.message:hover .message-menu-trigger,
.message-menu-trigger:focus-visible {
  opacity: 1;
}

.message-bubble {
  border-radius: 16px;
  padding: 8px 11px;
  box-shadow: 0 1px 1px rgba(21, 41, 58, 0.16);
}

.message.mine .message-bubble {
  background: #d9fdd3;
  border-bottom-right-radius: 5px;
}

.message:not(.mine) .message-bubble {
  background: #fff;
  border-bottom-left-radius: 5px;
}

.composer {
  grid-template-columns: 42px 42px minmax(0, 1fr) 46px;
  align-items: end;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(215, 228, 238, 0.96);
}

.composer textarea {
  min-height: 44px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(28, 47, 65, 0.14);
}

.composer .icon-button {
  color: #6b7f91;
}

.send-button {
  width: 46px;
  height: 46px;
  box-shadow: 0 3px 10px rgba(34, 158, 217, 0.28);
}

@media (max-width: 760px) {
  .messenger-view {
    grid-template-columns: 1fr;
  }

  .sidebar-header,
  .chat-header {
    min-height: 56px;
  }

  .message-list {
    gap: 6px;
    padding: 10px 8px;
  }

  .message {
    max-width: 88%;
  }

  .message-bubble {
    border-radius: 15px;
    padding: 8px 10px;
  }

  .chat-header-avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

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

html {
  -webkit-tap-highlight-color: transparent;
}

.chat-pane,
.sidebar,
.message,
.conversation-button,
.action-sheet-panel,
.media-viewer {
  will-change: transform, opacity;
}

.message {
  animation: message-rise 0.18s ease-out both;
}

.message.mine {
  transform-origin: right bottom;
}

.message:not(.mine) {
  transform-origin: left bottom;
}

@keyframes message-rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.conversation-button:active,
.icon-button:active,
.send-button:active {
  transform: scale(0.97);
}

.action-sheet:not([hidden]) {
  animation: sheet-fade 0.14s ease-out both;
}

.action-sheet:not([hidden]) .action-sheet-panel {
  animation: sheet-up 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.media-viewer:not([hidden]) {
  animation: viewer-in 0.18s ease-out both;
}

@keyframes viewer-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.recording {
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.28);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(217, 48, 37, 0);
  }
}

.record-cancel-hint {
  background: #fee2e2 !important;
  color: #b42318 !important;
  transform: translateX(-4px) scale(1.04);
}

.record-lock-hint {
  background: #e0f2fe !important;
  color: var(--accent) !important;
  transform: translateY(-5px) scale(1.04);
}

.voice-status {
  animation: voice-panel-in 0.16s ease-out both;
}

@keyframes voice-panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.edge-swipe-hint .chat-pane {
  transform: translateX(8px);
  transition: transform 0.14s ease-out;
}

@media (max-width: 760px) {
  .chat-pane {
    transition: transform 0.16s ease-out;
  }

  .messenger-view.chat-open .chat-pane {
    animation: chat-slide-in 0.18s ease-out both;
  }

  @keyframes chat-slide-in {
    from {
      opacity: 0.96;
      transform: translateX(20px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
