* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0e1621;
  --bg-panel: #17212b;
  --bg-sidebar: #17212b;
  --bg-hover: #202b36;
  --bg-active: #2b5278;
  --accent: #2ea6ff;
  --accent-2: #3fa9ea;
  --text: #e4e7eb;
  --text-dim: #7d8994;
  --text-faint: #5c6773;
  --border: #101921;
  --bubble-out: #2b5278;
  --bubble-in: #182533;
  --danger: #e05353;
  --radius: 10px;
}
html, body { height: 100%; height: 100dvh; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2b3a49; border-radius: 4px; }

.screen { height: 100vh; height: 100dvh; width: 100vw; }

/* ---------- Auth ---------- */
#auth-screen {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1c2c3d, #0e1621 70%);
}
.auth-card {
  background: var(--bg-panel); padding: 40px 36px; border-radius: 16px;
  width: 360px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.auth-logo {
  width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #1c7fd6);
  color: white; font-size: 32px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
.auth-tabs { display: flex; background: var(--bg-hover); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; border: none; background: transparent; color: var(--text-dim); padding: 8px; border-radius: 8px; font-size: 14px; }
.auth-tab.active { background: var(--accent); color: white; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form.hidden { display: none; }
.auth-form input {
  background: var(--bg-hover); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 14px; outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-error { color: var(--danger); font-size: 13px; min-height: 16px; text-align: left; }
.btn-primary {
  background: var(--accent); color: white; border: none; padding: 12px; border-radius: 10px;
  font-size: 15px; font-weight: 600; margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary {
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); padding: 10px; border-radius: 10px;
}

/* ---------- App layout ---------- */
.app-layout { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 380px; min-width: 320px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: relative;
}
.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 10px; }
.icon-btn {
  background: transparent; border: none; color: var(--text-dim); font-size: 18px; width: 40px; height: 40px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.search-box { flex: 1; }
.search-box input {
  width: 100%; background: var(--bg-hover); border: none; color: var(--text); padding: 10px 14px;
  border-radius: 20px; outline: none; font-size: 14px;
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; cursor: pointer;
  margin: 1px 6px; border-radius: 12px; transition: background .12s;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-item.active .chat-item-preview,
.chat-item.active .chat-item-time { color: #c7dcf0; }
.chat-item.active .unread-badge { background: white; color: var(--bg-active); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, #7c5cff, #2ea6ff);
  color: white; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600;
  flex-shrink: 0; overflow: hidden; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.chat-item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.chat-item-preview { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge {
  background: var(--accent); color: white; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0;
}
.online-dot {
  width: 12px; height: 12px; background: #4fce5d; border: 2px solid var(--bg-sidebar); border-radius: 50%;
  position: absolute; bottom: -1px; right: -1px;
}
.chat-type-icon { font-size: 12px; margin-right: 3px; color: var(--text-dim); }

.sidebar-fab-wrap { position: absolute; bottom: 20px; right: 20px; }
.fab {
  width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: white; border: none;
  font-size: 26px; box-shadow: 0 4px 16px rgba(46,166,255,.35); transition: transform .15s, background .15s;
}
.fab:hover { background: var(--accent-2); transform: scale(1.06); }
.fab:active { transform: scale(.95); }

/* ---------- Chat panel ---------- */
/* Обои чата в духе Telegram: тёмный градиент + мягкий повторяющийся узор */
.chat-panel {
  flex: 1; display: flex; flex-direction: column; position: relative;
  background:
    radial-gradient(circle at 18% 16%, rgba(46,166,255,.10), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(124,92,255,.10), transparent 45%),
    #0d151f;
}
.chat-panel::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><g fill="none" stroke="%23ffffff" stroke-opacity="0.028" stroke-width="1.5"><circle cx="20" cy="20" r="9"/><circle cx="80" cy="45" r="6"/><circle cx="45" cy="85" r="7.5"/><circle cx="100" cy="100" r="5"/><path d="M60 12c4 4 4 9 0 13"/><path d="M12 62c5 3 5 9 0 12"/></g></svg>');
}
.chat-panel > * { position: relative; z-index: 1; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-faint); gap: 16px; }
.chat-empty-icon {
  width: 80px; height: 80px; border-radius: 50%; background: var(--bg-panel); display: flex; align-items: center;
  justify-content: center; font-size: 36px; color: var(--text-faint);
}
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg-panel);
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.chat-header-body { flex: 1; min-width: 0; }
.chat-header-name { font-size: 16px; font-weight: 600; }
.chat-header-status { font-size: 13px; color: var(--text-dim); }
.chat-header-actions { display: flex; gap: 4px; }
.back-btn { display: none; font-size: 26px; flex-shrink: 0; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.msg-row { display: flex; gap: 8px; max-width: 70%; align-items: flex-end; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.in { align-self: flex-start; }
.msg-bubble {
  background: var(--bubble-in); padding: 7px 10px; position: relative; min-width: 60px;
  border-radius: 14px 14px 14px 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.22);
  animation: msg-in .18s ease-out;
}
.msg-row.out .msg-bubble { background: var(--bubble-out); border-radius: 14px 14px 5px 14px; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .msg-bubble, .modal { animation: none !important; }
}
.msg-sender-name { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.role-badge { font-size: .9em; }
.user-nickname { font-size: .85em; color: var(--text-dim); font-weight: 400; font-style: italic; }
.chat-header-name .role-badge, .chat-header-name .user-nickname { font-size: 13px; }
.msg-reply {
  background: rgba(255,255,255,.06); border-left: 3px solid var(--accent); padding: 4px 8px; border-radius: 6px;
  margin-bottom: 4px; font-size: 12.5px; color: var(--text-dim); cursor: pointer;
}
.msg-reply b { color: var(--accent); display: block; font-size: 12px; }
.msg-text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; line-height: 1.35; }
.msg-meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; float: right; margin-left: 10px; }
.msg-time { font-size: 11px; color: var(--text-faint); }
.msg-row.out .msg-time { color: #a9c6de; }
.msg-ticks { font-size: 12px; color: #a9c6de; }
.msg-edited { font-size: 11px; color: var(--text-faint); font-style: italic; }
.msg-attachment img, .msg-attachment video { max-width: 280px; max-height: 320px; border-radius: 8px; display: block; margin-top: 4px; }
.msg-file { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.06); padding: 8px; border-radius: 8px; margin-top: 4px; text-decoration: none; color: inherit; }
.msg-file-icon { font-size: 20px; }
.msg-audio { margin-top: 4px; }
.msg-audio audio { width: 240px; }
.msg-sticker { font-size: 64px; line-height: 1; }
.msg-reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.reaction-chip { background: rgba(255,255,255,.08); border-radius: 10px; padding: 1px 7px; font-size: 12.5px; cursor: pointer; border: 1px solid transparent; }
.reaction-chip.mine { border-color: var(--accent); background: rgba(46,166,255,.18); }
.msg-actions { display: none; gap: 2px; position: absolute; top: -14px; right: 4px; background: var(--bg-panel); border-radius: 8px; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.msg-row.out .msg-actions { right: auto; left: 4px; }
.msg-bubble:hover .msg-actions { display: flex; }
.msg-actions button { background: none; border: none; color: var(--text-dim); font-size: 13px; padding: 4px 6px; border-radius: 4px; }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }
.msg-date-sep {
  align-self: center; background: rgba(0,0,0,.38); color: #cfd8e0; font-size: 12px; font-weight: 500;
  padding: 4px 12px; border-radius: 12px; margin: 12px 0; backdrop-filter: blur(6px);
}

.typing-indicator { padding: 4px 16px; font-size: 12.5px; color: var(--accent); font-style: italic; min-height: 20px; }

.attachments-preview { display: flex; gap: 8px; padding: 8px 16px; background: var(--bg-panel); border-top: 1px solid var(--border); flex-wrap: wrap; }
.attachment-chip { position: relative; background: var(--bg-hover); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.attachment-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.attachment-chip .remove-chip { background: none; border: none; color: var(--text-dim); font-size: 14px; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--bg-panel); border-top: 1px solid var(--border); }
.reply-bar-body { flex: 1; border-left: 3px solid var(--accent); padding-left: 8px; font-size: 13px; }
.reply-bar-body b { display: block; color: var(--accent); font-size: 12.5px; }
.reply-bar-close { background: none; border: none; color: var(--text-dim); font-size: 18px; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; background: var(--bg-panel); border-top: 1px solid var(--border); }
.composer-input-wrap { flex: 1; }
#message-input {
  width: 100%; background: var(--bg-hover); border: none; color: var(--text); padding: 10px 14px; border-radius: 20px;
  outline: none; font-size: 14.5px; resize: none; max-height: 140px; line-height: 1.4;
}
.send-btn { background: var(--accent); color: white; }
.send-btn:hover { background: var(--accent-2); }
.composer-locked {
  text-align: center; padding: 12px; color: var(--text-dim); font-size: 13px;
  background: var(--bg-panel); border-top: 1px solid var(--border);
}

.emoji-picker {
  position: absolute; bottom: 64px; left: 12px; width: 320px; max-height: 260px; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 20;
}
.emoji-picker span { font-size: 22px; cursor: pointer; text-align: center; padding: 4px; border-radius: 6px; }
.emoji-picker span:hover { background: var(--bg-hover); }
.emoji-picker .sticker-tab-row { grid-column: 1/-1; display: flex; gap: 6px; margin-bottom: 6px; }
.emoji-picker .sticker-tab-row button { flex: 1; background: var(--bg-hover); border: none; color: var(--text-dim); border-radius: 6px; padding: 4px; font-size: 12px; }
.emoji-picker .sticker-tab-row button.active { background: var(--accent); color: white; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(3px);
}
.modal {
  background: var(--bg-panel); border-radius: 16px; padding: 24px; width: 400px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; position: relative; box-shadow: 0 16px 48px rgba(0,0,0,.5);
  animation: modal-in .18s cubic-bezier(.2,.9,.3,1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal input, .modal textarea {
  width: 100%; background: var(--bg-hover); border: 1px solid var(--border); color: var(--text); padding: 10px 12px;
  border-radius: 10px; outline: none; font-size: 14px; margin-bottom: 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.user-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.user-pick-row:hover { background: var(--bg-hover); }
.user-pick-row.selected { background: var(--bg-active); }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px; }
.member-role { font-size: 12px; color: var(--text-dim); margin-left: auto; }
.modal-close-x { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-dim); font-size: 20px; }
.profile-field-label { font-size: 12px; color: var(--text-dim); margin-top: 10px; margin-bottom: 4px; }
.danger-link { color: var(--danger); font-size: 14px; cursor: pointer; padding: 8px 0; }
.btn-sm { padding: 6px 12px; border-radius: 8px; font-size: 12.5px; border: none; }
.btn-ghost { background: var(--bg-hover); color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-active); color: var(--text); }

/* ---------- Боковое меню (drawer) ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 150; animation: fade-in .15s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 300px; max-width: 82vw;
  background: var(--bg-panel); box-shadow: 4px 0 24px rgba(0,0,0,.45);
  display: flex; flex-direction: column; padding-bottom: 12px; overflow-y: auto;
  animation: drawer-in .22s cubic-bezier(.2,.9,.3,1);
}
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-head {
  padding: 20px 18px 16px; background: linear-gradient(135deg, #1c3a5c, #17212b);
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.drawer-name { font-size: 16px; font-weight: 600; margin-top: 10px; }
.drawer-username { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.drawer-item {
  display: flex; align-items: center; gap: 14px; width: 100%; background: none; border: none;
  color: var(--text); padding: 12px 18px; font-size: 14.5px; text-align: left; transition: background .12s;
}
.drawer-item:hover { background: var(--bg-hover); }
.drawer-ico { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.drawer-label { flex: 1; }
.drawer-badge {
  background: var(--accent); color: white; font-size: 12.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 12px;
}
.drawer-sep { height: 1px; background: var(--border); margin: 8px 14px; }
.drawer-danger { color: var(--danger); }
@supports (padding: max(0px)) {
  .drawer-head { padding-top: max(20px, env(safe-area-inset-top)); }
}

/* ---------- Звёзды и рынок ---------- */
.stars-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; background: var(--bg-hover);
  border: 1px solid var(--border); color: var(--accent); padding: 7px 14px; border-radius: 18px;
  font-size: 13px; font-weight: 600;
}
.stars-chip:hover { background: var(--bg-active); color: var(--text); }
.stars-balance-card {
  background: linear-gradient(135deg, rgba(46,166,255,.16), rgba(124,92,255,.14));
  border: 1px solid rgba(46,166,255,.25); border-radius: 14px; padding: 16px; text-align: center; margin-bottom: 14px;
}
.stars-balance-num { font-size: 26px; font-weight: 700; color: var(--accent); }
.stars-balance-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.seg-tabs { display: flex; background: var(--bg-hover); border-radius: 10px; padding: 3px; margin-bottom: 14px; gap: 2px; }
.seg-tab {
  flex: 1; border: none; background: transparent; color: var(--text-dim); padding: 8px 6px;
  border-radius: 8px; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.seg-tab.active { background: var(--accent); color: white; }

.nft-list { display: flex; flex-direction: column; gap: 8px; }
.nft-row {
  display: flex; align-items: center; gap: 10px; background: var(--bg-hover);
  border: 1px solid transparent; border-radius: 12px; padding: 9px 10px;
}
.nft-row.on-sale { border-color: rgba(46,166,255,.35); }
.nft-row-body { flex: 1; min-width: 0; }
.nft-row-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nft-row-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.market-empty { text-align: center; color: var(--text-dim); padding: 28px 12px; font-size: 32px; }
.market-empty div { font-size: 14px; margin-top: 8px; }

.rarity-tag {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 9px; border: 1px solid currentColor; opacity: .95;
}
.nft-row-price { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.nft-row-price b { color: var(--accent); }
.econ-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.econ-cell { background: var(--bg-hover); border-radius: 10px; padding: 9px 6px; text-align: center; }
.econ-cell .n { font-size: 16px; font-weight: 700; color: var(--accent); }
.econ-cell .l { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.25; }
.split-note {
  background: var(--bg-hover); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.45;
}

/* ---------- История имён ---------- */
.nh-list { display: flex; flex-direction: column; gap: 8px; }
.nh-row { background: var(--bg-hover); border-radius: 10px; padding: 10px 12px; border-left: 3px solid transparent; }
.nh-row.current { border-left-color: var(--accent); }
.nh-name { font-size: 14px; font-weight: 500; }
.nh-tag { font-size: 11px; color: var(--accent); font-weight: 400; }
.nh-username { font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }
.nh-date { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

/* ---------- Calls ---------- */
.call-overlay { position: fixed; inset: 0; background: rgba(10,16,24,.96); display: flex; align-items: center; justify-content: center; z-index: 200; }
.call-box { text-align: center; position: relative; }
.call-name { font-size: 22px; font-weight: 600; margin-top: 16px; }
.call-status { color: var(--text-dim); margin-top: 6px; }
.call-video { width: 480px; max-width: 90vw; border-radius: 12px; margin-top: 16px; background: #000; }
.call-video-local { position: absolute; width: 140px; bottom: 90px; right: -60px; border-radius: 10px; background: #000; }
.call-actions { display: flex; gap: 24px; justify-content: center; margin-top: 28px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; border: none; font-size: 24px; color: white; }
.call-btn.accept { background: #4fce5d; }
.call-btn.reject { background: var(--danger); }
.call-btn.toggle { background: rgba(255,255,255,.12); }
.call-btn.toggle.muted { background: var(--danger); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(28,40,54,.97); color: var(--text);
  padding: 11px 20px; border-radius: 12px; box-shadow: 0 6px 22px rgba(0,0,0,.5); z-index: 300; font-size: 14px;
  max-width: 90vw; text-align: center; animation: toast-in .2s ease-out; backdrop-filter: blur(8px);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%); }
}

@media (max-width: 860px) {
  .sidebar { width: 100%; position: absolute; inset: 0; z-index: 10; }
  .app-layout.chat-open .sidebar { display: none; }
  .chat-panel { width: 100%; }

  .back-btn { display: flex; }

  /* Не даём iOS Safari увеличивать масштаб при фокусе на поле ввода */
  input, textarea, select { font-size: 16px !important; }
  #message-input { font-size: 16px; }

  .auth-card { width: 100%; max-width: 360px; padding: 32px 22px; }

  .msg-row { max-width: 85%; }

  .modal { width: 100%; max-width: 420px; padding: 20px 16px; margin: 0 12px; max-height: 88dvh; }

  .emoji-picker { width: calc(100vw - 24px); left: 12px; right: 12px; }

  .composer { padding: 8px; gap: 4px; }
  .icon-btn { width: 36px; height: 36px; font-size: 17px; }
  #message-input { padding: 9px 12px; }

  .chat-item { padding: 9px 10px; margin: 1px 4px; }
  .avatar { width: 48px; height: 48px; }
  .seg-tab { font-size: 12.5px !important; padding: 8px 4px; }

  .call-video-local { width: 96px; right: 8px; bottom: 100px; }
  .call-actions { gap: 16px; }
  .call-btn { width: 54px; height: 54px; font-size: 20px; }

  .sidebar-fab-wrap { bottom: 16px; right: 16px; }
}

@media (max-width: 400px) {
  .auth-card { padding: 26px 16px; }
  .call-actions { gap: 10px; }
  .call-btn { width: 48px; height: 48px; font-size: 18px; }
  .msg-text { font-size: 14px; }
}

/* Область небезопасна на телефонах с вырезом/индикатором свайпа снизу */
@supports (padding: max(0px)) {
  .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .sidebar-header { padding-top: max(10px, env(safe-area-inset-top)); }
  .call-actions { margin-bottom: env(safe-area-inset-bottom); }
}
