:root {
  --bg: #0e1621;
  --panel: #17212b;
  --panel-2: #232e3c;
  --line: #0e1621;
  --text: #f5f5f5;
  --muted: #708499;
  --accent: #2aabee;
  --accent-hover: #1e96d1;
  --danger: #e53935;
  --bubble-me: #2b5278;
  --bubble-them: #182533;
  --ok: #4fae4e;
  --font: "Manrope", "Segoe UI", sans-serif;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

.hidden { display: none !important; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost {
  background: var(--panel-2);
  color: var(--text);
  flex: 1;
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
}

.error {
  color: #ff8a80;
  min-height: 1.2em;
  font-size: 0.85rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.field input,
.field select,
.composer textarea,
.modal input,
.modal select {
  width: 100%;
  border: 0;
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font: inherit;
  outline: none;
}
.field input:focus,
.composer textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(42, 171, 238, 0.45);
}

/* ——— Vault security screen ——— */
.vault-screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(42, 171, 238, 0.22), transparent 55%),
    linear-gradient(180deg, #0b121a 0%, #0e1621 50%, #101820 100%);
  padding: 1.25rem 1rem 0;
  display: block;
}
.vault-inner {
  width: min(560px, 100%);
  margin: 0 auto;
  padding-bottom: 0.5rem;
  animation: rise 0.55s ease both;
}
.vault-shield {
  width: 84px;
  height: 84px;
  margin: 0 auto 0.75rem;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: rgba(42, 171, 238, 0.12);
  animation: pulseShield 2.4s ease-in-out infinite;
}
.vault-brand {
  text-align: center;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.78rem;
}
.vault-inner h1 {
  text-align: center;
  font-size: clamp(1.45rem, 4.5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.25;
  margin: 0.55rem 0 0.75rem;
}
.vault-lead {
  text-align: center;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 1.15rem;
  font-size: 0.95rem;
}
.vault-lead strong { color: #d7ebf8; font-weight: 700; }

.vault-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.vault-card {
  background: rgba(23, 33, 43, 0.9);
  border: 1px solid rgba(42, 171, 238, 0.18);
  border-radius: 12px;
  padding: 0.7rem 0.45rem;
  text-align: center;
}
.vc-code {
  display: block;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #7ad3ff;
  letter-spacing: 0.02em;
}
.vault-card small {
  color: var(--muted);
  font-size: 0.68rem;
}

.vault-seal {
  display: grid;
  gap: 0.55rem;
  background: #121b24;
  border: 1px solid rgba(42, 171, 238, 0.25);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.seal-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-family: var(--font);
  margin-bottom: 0.15rem;
}
.vault-seal code {
  color: #e8f6ff;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}
.vault-seal code.ok { color: var(--ok); }

.vault-points {
  margin: 0 0 1.1rem;
  padding: 0 0 0 1.1rem;
  color: #b7c6d4;
  font-size: 0.88rem;
  line-height: 1.5;
}
.vault-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  margin: 0.5rem 0 0;
}

.vault-cta {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 0.75rem;
  padding: 0.85rem 0 calc(1rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(14, 22, 33, 0), #0e1621 28%);
}
.vault-cta .btn.primary {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@keyframes pulseShield {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 171, 238, 0.35); }
  50% { box-shadow: 0 0 0 14px rgba(42, 171, 238, 0); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ——— Auth (Telegram-like) ——— */
.gate {
  position: fixed;
  inset: 0;
  z-index: 3;
  height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: block;
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--bg);
}
.gate-panel {
  width: min(400px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border-radius: 16px;
  padding: 1.6rem 1.35rem 1.35rem;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
  text-align: center;
}
.tg-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2aabee, #1a7fb8);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}
.gate-panel h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
}
.lede {
  color: var(--muted);
  margin: 0.35rem 0 1rem;
  font-size: 0.92rem;
}
.sec-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-bottom: 1rem;
}
.sec-strip span {
  font-size: 0.68rem;
  font-weight: 700;
  color: #9fd9f5;
  background: rgba(42, 171, 238, 0.12);
  border: 1px solid rgba(42, 171, 238, 0.22);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}
.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 0.6rem;
  border-radius: 9px;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--panel-2);
  color: var(--text);
}
.auth-form { text-align: left; }
.gate-foot {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ——— App shell (Telegram-like) ——— */
.app {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  height: 100dvh;
  height: 100svh;
  max-height: 100dvh;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #0b121a;
}
.side-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  background: var(--panel);
}
.me-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font: inherit;
  min-width: 0;
}
.me-meta strong, .me-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.me-meta small { color: var(--muted); font-size: 0.75rem; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2aabee, #1578ad);
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.avatar.has-img { color: transparent; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.5rem; margin: 0 auto; }

.side-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0 0.85rem 0.65rem;
}
.side-search {
  padding: 0 0.85rem 0.65rem;
}
.side-search input {
  width: 100%;
  border: 0;
  background: var(--panel-2);
  color: var(--text);
  border-radius: 20px;
  padding: 0.65rem 1rem;
  font: inherit;
  outline: none;
}
.side-search input:focus {
  box-shadow: inset 0 0 0 2px rgba(42, 171, 238, 0.45);
}
.contacts-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem 0.55rem;
}
.contacts-toolbar .btn {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.55rem 0.75rem;
}
.contact-section-title {
  margin: 0.55rem 0.9rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.person.phone-only small {
  color: var(--muted);
}
.person .match-badge {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--ok);
  font-weight: 700;
}
.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid #0b121a;
}
.side-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 0.7rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.side-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.side-block {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0;
}
.list { display: grid; }

.person, .room {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  font: inherit;
}
.person:hover, .room:hover, .room.active {
  background: rgba(42, 171, 238, 0.1);
}
.meta { display: grid; gap: 0.1rem; min-width: 0; }
.meta strong, .room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.meta small { color: var(--muted); font-size: 0.75rem; }
.meta small.on { color: var(--ok); }
.room { justify-content: space-between; }
.room-badge {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
}
.empty-hint {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 1rem;
  margin: 0;
}

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid #0b121a;
  font-size: 0.75rem;
  color: var(--muted);
}
.status.online { color: var(--ok); }
.e2e-pill {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
}
.linkish {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  background: var(--bg);
  overflow: hidden;
}
.chat-foot {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  padding-top: calc(0.65rem + env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid #0b121a;
}
.chat-head-text { flex: 1; min-width: 0; }
.chat-head h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-head p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.head-lock { opacity: 0.85; }

.call-btns {
  display: flex;
  gap: 0.15rem;
  align-items: center;
}
.call-btns.hidden { display: none !important; }
.call-icon {
  font-size: 1.05rem;
  width: 36px;
  height: 36px;
}

.call-incoming {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 22, 0.88);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
}
.call-incoming-card {
  text-align: center;
  max-width: 320px;
  width: 100%;
  animation: callPulse 1.6s ease-in-out infinite;
}
.call-incoming-card h2 {
  margin: 0.85rem 0 0.25rem;
  font-size: 1.45rem;
}
.call-incoming-card p {
  margin: 0 0 1.4rem;
  color: var(--muted);
}
.call-incoming-actions {
  display: flex;
  justify-content: center;
  gap: 2.2rem;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #0a1018;
  display: grid;
  place-items: center;
}
.call-overlay.video-mode {
  background: #05080c;
}
.call-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a1018;
}
.call-overlay:not(.video-mode) .call-remote {
  opacity: 0;
  pointer-events: none;
}
.call-local {
  position: absolute;
  right: 1rem;
  top: calc(1rem + env(safe-area-inset-top));
  width: min(28vw, 140px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  background: #1a2430;
  box-shadow: var(--shadow);
  z-index: 2;
  transform: scaleX(-1);
}
.call-local.dimmed { opacity: 0.35; }
.call-overlay-ui {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
  margin-bottom: calc(2.5rem + env(safe-area-inset-bottom));
  width: 100%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55) 40%);
}
.call-overlay.ringing .call-overlay-ui,
.call-overlay:not(.video-mode) .call-overlay-ui {
  margin: auto;
  background: none;
}
.call-peer-name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 750;
}
.call-status {
  margin: 0.35rem 0 1.5rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.call-controls {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
}
.call-round {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.1s;
}
.call-round:active { transform: scale(0.94); }
.call-round.accept { background: #4fae4e; }
.call-round.reject { background: #e53935; }
.call-round.decline {
  background: #e53935;
  transform: rotate(135deg);
}
.call-round.decline:active { transform: rotate(135deg) scale(0.94); }
.call-round.active { background: rgba(255, 255, 255, 0.28); }

@keyframes callPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.emoji-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.45rem;
  overflow-x: auto;
  grid-column: 1 / -1;
}
.emoji-tabs button {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-tabs button.active {
  background: rgba(42, 171, 238, 0.2);
  color: var(--text);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.2rem;
  max-height: 180px;
  overflow: auto;
}

.messages {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  min-height: 0;
  padding: 0.75rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background-color: #0e1621;
  background-image:
    radial-gradient(rgba(42, 171, 238, 0.05) 1px, transparent 1px);
  background-size: 18px 18px;
}
.messages-spacer {
  flex: 1 1 auto;
  min-height: 0.25rem;
  pointer-events: none;
}
.date-chip {
  align-self: center;
  margin: 0.45rem 0 0.25rem;
  z-index: 1;
}
.date-chip span {
  display: inline-block;
  background: rgba(24, 37, 51, 0.95);
  color: #b7c6d4;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  user-select: none;
}
.welcome {
  margin: auto;
  text-align: center;
  width: 100%;
  max-width: min(320px, 100%);
  padding: 0 1.25rem;
  box-sizing: border-box;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.welcome p {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.welcome-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  font-size: 1.6rem;
}
.welcome h2 {
  margin: 0 0 0.4rem;
  color: var(--text);
  font-size: 1.25rem;
}
.welcome .btn {
  margin-top: 1rem;
  width: auto;
  min-width: 160px;
  display: inline-block;
}
.welcome-mobile { display: none; }
.welcome-desktop { display: block; }

.bubble {
  max-width: min(78%, 480px);
  align-self: flex-start;
  background: var(--bubble-them);
  border-radius: 14px 14px 14px 4px;
  padding: 0.55rem 0.7rem 0.35rem;
  animation: bubbleIn 180ms ease both;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--bubble-me);
  border-radius: 14px 14px 4px 14px;
}
.bubble header {
  font-size: 0.72rem;
  color: #7ad3ff;
  margin-bottom: 0.15rem;
  font-weight: 700;
}
.bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  font-size: 0.95rem;
}
.bubble time {
  display: inline;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
}
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.edited-mark {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}
.ticks {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.7rem;
  padding: 0;
  cursor: pointer;
  letter-spacing: -0.12em;
  line-height: 1;
}
.ticks.delivered { color: rgba(255, 255, 255, 0.55); }
.ticks.read { color: #7ad3ff; }
.bubble.deleted .bubble-body,
.deleted-text {
  color: var(--muted);
  font-style: italic;
}

.call-event {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: min(92%, 360px);
  width: 100%;
  margin: 0.35rem 0;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  background: rgba(35, 46, 60, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.call-event.mine {
  background: rgba(43, 82, 120, 0.55);
}
.call-event.miss {
  border-color: rgba(229, 57, 53, 0.35);
}
.call-event.ok .call-event-icon {
  color: #7ad3ff;
}
.call-event.miss .call-event-icon {
  color: #ff8a80;
}
.call-event-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.25);
  font-size: 1.15rem;
  flex-shrink: 0;
}
.call-event-text {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.call-event-text strong {
  font-size: 0.92rem;
  font-weight: 700;
}
.call-event-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.edit-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: #1c2a38;
  border-top: 1px solid #0b121a;
}
.edit-bar.hidden { display: none !important; }
.edit-bar-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}
.edit-bar-text strong {
  font-size: 0.78rem;
  color: var(--accent);
}
.edit-bar-text span {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-menu {
  position: fixed;
  z-index: 90;
  min-width: 180px;
  background: var(--panel-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  display: grid;
}
.msg-menu.hidden { display: none !important; }
.msg-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}
.msg-menu button:hover { background: rgba(42, 171, 238, 0.15); }
.msg-menu button.danger { color: #ff8a80; }
.msg-menu button[hidden] { display: none; }

.receipt-list { display: grid; gap: 0.55rem; margin-top: 0.75rem; }
.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
}
.receipt-row span { color: var(--muted); }

.composer {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  padding: 0.55rem 0.65rem calc(0.55rem + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid #0b121a;
  position: relative;
}
.composer.disabled { opacity: 0.55; }
.composer textarea {
  resize: none;
  min-height: 44px;
  max-height: 140px;
  border-radius: 22px;
  padding: 0.7rem 1rem;
  flex: 1;
}
.tool-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.tool-btn:disabled { opacity: 0.4; cursor: default; }

.emoji-panel {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: calc(100% + 0.35rem);
  max-height: 260px;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: 14px;
  padding: 0.55rem;
  box-shadow: var(--shadow);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.emoji-panel button[data-emoji] {
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 8px;
}
.emoji-panel button[data-emoji]:hover { background: rgba(42, 171, 238, 0.15); }

.bubble .media {
  display: block;
  max-width: min(260px, 70vw);
  border-radius: 10px;
  margin: 0.15rem 0 0.25rem;
}
.bubble video.media {
  background: #000;
  max-height: 280px;
}
.bubble .file-card {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  margin: 0.15rem 0 0.25rem;
  text-decoration: none;
  color: inherit;
  max-width: 260px;
}
.bubble .file-card strong {
  font-size: 0.85rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble .file-card small {
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
}
.send-fab {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.send-fab:disabled { opacity: 0.45; cursor: default; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font: inherit;
  font-size: 1.25rem;
}
.mobile-only { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
}
.modal.open { display: grid; }
.modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow);
  max-height: 90dvh;
  overflow: auto;
}
.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-card h2 {
  margin: 0;
  font-size: 1.15rem;
}
.modal-hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.pick-list {
  display: grid;
  gap: 0.35rem;
  max-height: 220px;
  overflow: auto;
  margin: 0.75rem 0 1rem;
}
.pick {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
}
.profile-preview { text-align: center; margin-bottom: 1rem; }
.sep {
  border: 0;
  border-top: 1px solid #0b121a;
  margin: 1.1rem 0;
}
.subhead {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}
.camo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.75rem 0 1rem;
  max-height: 240px;
  overflow: auto;
}
.camo-pick {
  display: grid;
  gap: 0.25rem;
  justify-items: center;
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
}
.camo-pick input { position: absolute; opacity: 0; pointer-events: none; }
.camo-pick img { width: 44px; height: 44px; border-radius: 12px; }
.camo-pick.active,
.camo-pick:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(120%);
  z-index: 30;
  background: var(--panel-2);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Lock / decoy — экран как у банковского приложения */
.lock-screen, .decoy-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--lock-bg, var(--bg));
}
.lock-card, .decoy-card {
  width: min(380px, 100%);
  text-align: center;
  padding: 1.8rem 1.35rem 1.5rem;
  border-radius: 20px;
  background: var(--lock-card, var(--panel));
  box-shadow: var(--shadow);
  color: var(--lock-fg, var(--text));
}
.lock-screen[data-theme="tbank"] {
  --lock-bg: #111111;
  --lock-card: #1a1a1a;
  --lock-fg: #ffffff;
  --lock-accent: #ffdd2d;
}
.lock-screen[data-theme="sber"] {
  --lock-bg: #0b1f14;
  --lock-card: #123222;
  --lock-fg: #ffffff;
  --lock-accent: #21a038;
}
.lock-screen[data-theme="alfa"] {
  --lock-bg: #ef3124;
  --lock-card: #ffffff;
  --lock-fg: #111111;
  --lock-accent: #ef3124;
}
.lock-screen[data-theme="ozon"] {
  --lock-bg: #005bff;
  --lock-card: #ffffff;
  --lock-fg: #111111;
  --lock-accent: #005bff;
}
.lock-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  margin-bottom: 0.85rem;
  background: #222;
}
.lock-card h1, .decoy-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  color: inherit;
}
.lock-hint { color: var(--muted); margin: 0 0 1rem; }
.lock-screen[data-theme] .lock-hint { color: rgba(255,255,255,0.65); }
.lock-screen[data-theme="alfa"] .lock-hint,
.lock-screen[data-theme="ozon"] .lock-hint { color: rgba(0,0,0,0.55); }
.lock-pin {
  width: 100%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border-radius: 14px;
  padding: 0.95rem 1rem;
  font: inherit;
  font-size: 1.45rem;
  letter-spacing: 0.4em;
  text-align: center;
  margin-bottom: 0.85rem;
}
.lock-screen[data-theme="alfa"] .lock-pin,
.lock-screen[data-theme="ozon"] .lock-pin {
  background: rgba(0, 0, 0, 0.06);
}
.lock-screen .btn.primary {
  background: var(--lock-accent, var(--accent));
  color: #111;
}
.lock-screen[data-theme="sber"] .btn.primary,
.lock-screen[data-theme="ozon"] .btn.primary,
.lock-screen[data-theme="alfa"] .btn.primary,
.lock-screen:not([data-theme]) .btn.primary {
  color: #fff;
}
.lock-screen[data-theme="tbank"] .btn.primary { color: #111; }
.decoy-store {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
  text-align: center;
  text-decoration: none;
}
.decoy-card .btn.primary {
  display: block;
  text-decoration: none;
  margin-top: 0.5rem;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .welcome-desktop { display: none !important; }
  .welcome-mobile { display: block; }
  .welcome .btn.welcome-mobile {
    display: inline-block;
    margin-top: 1rem;
  }
  .app {
    grid-template-columns: 1fr;
    height: 100%;
    height: 100dvh;
    height: 100svh;
    height: -webkit-fill-available;
  }
  /* Как в Telegram: список чатов — основной экран на телефоне */
  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    z-index: 6;
    transform: none;
    transition: transform 0.22s ease;
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
  }
  .app.showing-chat .sidebar {
    transform: translateX(-105%);
    pointer-events: none;
  }
  .chat {
    position: fixed;
    inset: 0;
    z-index: 5;
    height: 100%;
    max-height: 100%;
    width: 100%;
  }
  .app:not(.showing-chat) .chat {
    visibility: hidden;
    pointer-events: none;
  }
  .messages {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
  .side-head .mobile-only { display: none !important; } /* X не нужен — список на весь экран */
  .vault-grid { grid-template-columns: repeat(2, 1fr); }
  .vault-inner h1 { font-size: 1.35rem; }
  .vault-lead { font-size: 0.9rem; margin-bottom: 0.85rem; }
  .vault-points { font-size: 0.82rem; margin-bottom: 0.5rem; }
  .vault-seal { margin-bottom: 0.75rem; padding: 0.75rem 0.85rem; }
  .bubble { max-width: min(88%, 480px); }
}

@media (min-width: 861px) {
  .app { max-width: 1400px; margin: 0 auto; }
  .welcome-mobile { display: none !important; }
  .welcome-desktop { display: block; }
}
