/* ═══════════════════════════════════════════════════════════
   VOISIO — compact mobile / native app shell
   Active when html[data-mobile="1"] (phone or Capacitor).
   ═══════════════════════════════════════════════════════════ */

html[data-mobile="1"] {
  --mobile-tabbar-h: 64px;
  --mobile-safe-b: env(safe-area-inset-bottom, 0px);
  --mobile-safe-t: env(safe-area-inset-top, 0px);
}

html[data-mobile="1"],
html[data-mobile="1"] body,
html[data-native="1"],
html[data-native="1"] body {
  height: 100% !important;
  min-height: 100% !important;
  overflow: hidden;
}

html[data-mobile="1"] body {
  padding: 0;
  background: #0a0d12;
}

html[data-mobile="1"] #app {
  min-height: 100dvh;
  min-height: 100svh;
}

html[data-native="1"] .desktop-hide,
html[data-native="1"] #btn-download-client,
html[data-native="1"] #btn-download-client-auth,
html[data-native="1"] #btn-download-android-auth {
  display: none !important;
}

html[data-mobile="1"] #friends-home,
html[data-mobile="1"] #home-requests-box {
  display: none !important;
}

html[data-mobile="1"].auth-mode,
html[data-mobile="1"] body.auth-mode {
  overflow: auto;
}

html[data-mobile="1"] body.auth-mode #app {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100svh;
}

html[data-mobile="1"] body.auth-mode #main,
html[data-mobile="1"] body.auth-mode .mobile-tabbar {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html[data-mobile="1"] #auth-panel {
  width: min(420px, calc(100vw - 28px));
  margin: calc(24px + var(--mobile-safe-t)) auto 24px;
  padding: 22px 18px 20px;
  border-radius: 20px;
  animation: mobile-fade-up 0.4s ease;
  flex: 0 0 auto;
  position: relative;
  left: auto;
  right: auto;
  transform: none;
}

html[data-mobile="1"] #auth-panel .logo-text { font-size: 26px; }

html[data-mobile="1"] .auth-field input,
html[data-mobile="1"] .auth-btn {
  min-height: 46px;
  font-size: 16px;
}

html[data-mobile="1"] #main {
  display: flex !important;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  padding-top: var(--mobile-safe-t);
  padding-bottom: calc(var(--mobile-tabbar-h) + var(--mobile-safe-b));
  overflow: hidden;
  grid-template-columns: none !important;
  background: #0e1218;
  opacity: 1 !important;
}

html[data-mobile="1"] #main.hidden {
  display: none !important;
}

/* WebView keeps fill-mode animations stuck at opacity 0 after the splash. */
html[data-mobile="1"] #main > *,
html[data-design="new"][data-mobile="1"] #main > * {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

html[data-mobile="1"] .nav-sidebar,
html[data-mobile="1"] .topbar,
html[data-mobile="1"] .sidebar-topbar,
html[data-mobile="1"] .sidebar-nav-tabs,
html[data-mobile="1"] .sidebar-actions-slot,
html[data-mobile="1"] .brand {
  display: none !important;
}

/* Profile bar is desktop-only. The «Я» sheet is moved to document.body. */
html[data-mobile="1"] .profile {
  display: none !important;
}

html[data-mobile="1"] .sidebar,
html[data-mobile="1"] .sidebar-scroll,
html[data-mobile="1"] #panel-chats {
  min-height: 0;
  flex: 1 1 auto;
}

html[data-mobile="1"] .sidebar {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  border: none;
  padding: 10px 12px 6px;
  display: flex !important;
  flex-direction: column;
  background: #0e1218;
  opacity: 1 !important;
  animation: none !important;
  transform: none !important;
}

html[data-mobile="1"] #main.mobile-chat-active .sidebar { display: none !important; }
html[data-mobile="1"] #main:not(.mobile-chat-active) .content { display: none !important; }
html[data-mobile="1"] #main.mobile-chat-active { padding-bottom: var(--mobile-safe-b); }
html[data-mobile="1"] #main.mobile-chat-active .mobile-tabbar { display: none; }

html[data-mobile="1"] .sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html[data-mobile="1"] .mobile-servers-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 12px;
  margin-bottom: 8px;
}

html[data-mobile="1"] .mobile-servers-bar.hidden { display: none !important; }

html[data-mobile="1"] .mobile-servers-bar-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

html[data-mobile="1"] .mobile-servers-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 6px;
}

html[data-mobile="1"] .mobile-servers-slot .server-list,
html[data-mobile="1"] .mobile-servers-slot .nav-bottom {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  max-height: none;
  overflow: visible;
  padding: 0;
}

html[data-mobile="1"] .mobile-servers-slot .nav-divider,
html[data-mobile="1"] .mobile-servers-slot .nav-section-label { display: none !important; }

html[data-mobile="1"] .mobile-servers-slot .server-btn,
html[data-mobile="1"] .mobile-servers-slot .server-btn-avatar,
html[data-mobile="1"] .mobile-servers-slot .nav-btn {
  width: 52px;
  height: 52px;
  min-width: 52px;
}

html[data-mobile="1"] .mobile-servers-slot .server-btn {
  border-radius: 16px;
  background: #171d27;
  border: 1.5px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

html[data-mobile="1"] .mobile-servers-slot .server-btn.active {
  border-color: #1fbf9a;
  box-shadow: 0 0 0 3px rgba(31, 191, 154, 0.22), 0 8px 18px rgba(31, 191, 154, 0.16);
}

html[data-mobile="1"] .mobile-servers-slot .server-btn::before { display: none; }

html[data-mobile="1"] .mobile-servers-slot .nav-btn {
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(31, 191, 154, 0.22), rgba(31, 191, 154, 0.06));
  border: 1.5px dashed rgba(31, 191, 154, 0.45);
  color: #7ee8cb;
}

html[data-mobile="1"] .mobile-server-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

html[data-mobile="1"] .mobile-server-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  color: #eef1f4;
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

html[data-mobile="1"] .mobile-server-card:active {
  transform: scale(0.985);
}

html[data-mobile="1"] .mobile-server-card.active {
  border-color: rgba(31, 191, 154, 0.5);
  background:
    linear-gradient(180deg, rgba(31, 191, 154, 0.18), rgba(31, 191, 154, 0.08));
  box-shadow: 0 0 0 1px rgba(31, 191, 154, 0.18), 0 12px 28px rgba(31, 191, 154, 0.1);
}

html[data-mobile="1"] .mobile-server-card-ava {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #171d27;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

html[data-mobile="1"] .mobile-server-card-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

html[data-mobile="1"] .mobile-server-card-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

html[data-mobile="1"] .mobile-server-card-name {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-mobile="1"] .mobile-server-card-sub {
  font-size: 12px;
  color: #8b93a1;
}

html[data-mobile="1"] .mobile-server-card-unread {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e85d5d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

html[data-mobile="1"] .mobile-server-card-chevron {
  width: 22px;
  height: 22px;
  color: #6d7686;
  flex-shrink: 0;
}

html[data-mobile="1"] #main[data-mobile-tab="servers"]:not(.has-server) #friend-list {
  display: none;
}

html[data-mobile="1"] .mobile-empty {
  padding: 18px 8px;
  color: #8b93a1;
  font-size: 14px;
  text-align: center;
}

html[data-mobile="1"] .list .item {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 14px;
  gap: 12px;
  opacity: 1;
}

html[data-mobile="1"] .list .item .avatar { width: 42px; height: 42px; }

html[data-mobile="1"] .channel-item {
  min-height: 46px;
  padding: 11px 12px;
  border-radius: 12px;
}

html[data-mobile="1"] .sidebar-header {
  font-size: 16px;
  padding: 8px 4px 10px;
}

html[data-mobile="1"] .server-header-card {
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 10px;
}

html[data-mobile="1"] .content,
html[data-mobile="1"] .content-body {
  flex: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

html[data-mobile="1"] .chat.panel {
  height: 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  opacity: 1;
}

html[data-mobile="1"] .chat-header {
  margin: 0;
  padding: 8px 8px 8px 4px;
  min-height: 56px;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-mobile="1"] .mobile-back-btn,
html[data-mobile="1"] .mobile-only {
  display: grid !important;
  place-items: center;
}

html[data-mobile="1"] .mobile-back-btn {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  font-size: 0;
}

html[data-mobile="1"] .chat-header-btn-label { display: none; }

html[data-mobile="1"] .chat-header-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
}

html[data-mobile="1"] #btn-members-toggle { display: inline-flex !important; }

html[data-mobile="1"] .chat-header-right {
  gap: 6px;
  overflow-x: auto;
}

html[data-mobile="1"] .chat-header-left { min-width: 0; flex: 1; }
html[data-mobile="1"] .chat-header-left img,
html[data-mobile="1"] .chat-avatar { width: 36px; height: 36px; }
html[data-mobile="1"] #chat-title { font-size: 15px; font-weight: 650; }

html[data-mobile="1"] .chat-messages { padding: 12px 12px 8px; }

html[data-mobile="1"] .msg-item {
  animation: mobile-fade-up 0.22s ease;
}

html[data-mobile="1"] .chat-input {
  margin: 6px 8px calc(8px + var(--mobile-safe-b));
  border-radius: 18px;
  min-height: 52px;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

html[data-mobile="1"] #btn-format-text { display: none !important; }
html[data-mobile="1"] #btn-voice-record,
html[data-mobile="1"] #btn-video-circle,
html[data-mobile="1"] #btn-attach,
html[data-mobile="1"] .composer-tools-left .icon-btn {
  display: grid !important;
  width: 42px;
  height: 42px;
  min-width: 42px;
  place-items: center;
}

html[data-mobile="1"] .composer-tools-left .icon-btn:nth-child(n+3) {
  display: grid !important;
}

html[data-mobile="1"] #message-input,
html[data-mobile="1"] .chat-input textarea {
  font-size: 16px;
  min-height: 42px;
  flex: 1 1 140px;
}

html[data-mobile="1"] .chat-input .char-count { display: none; }

.mobile-tabbar { display: none; }

html[data-mobile="1"] .mobile-tabbar {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  height: calc(var(--mobile-tabbar-h) + var(--mobile-safe-b));
  padding: 6px 8px var(--mobile-safe-b);
  background: rgba(7, 9, 13, 0.94);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

html[data-mobile="1"] .mobile-tab {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: #8b93a1;
  font-size: 10px;
  font-weight: 650;
  padding: 4px 2px;
  border-radius: 12px;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

html[data-mobile="1"] .mobile-tab:active { transform: scale(0.92); }
html[data-mobile="1"] .mobile-tab-ico { display: grid; place-items: center; width: 26px; height: 26px; }
html[data-mobile="1"] .mobile-tab.active {
  color: #9fe8d4;
  background: rgba(31, 191, 154, 0.12);
}

html[data-mobile="1"] .mobile-tab-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e85d5d;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

html[data-mobile="1"] .mobile-tab-badge.hidden { display: none !important; }

html[data-mobile="1"] .profile-menu {
  position: fixed !important;
  left: 10px;
  right: 10px;
  bottom: calc(12px + var(--mobile-tabbar-h) + var(--mobile-safe-b));
  top: auto;
  width: auto;
  max-height: min(72dvh, 620px);
  overflow: auto;
  z-index: 220;
  border-radius: 18px;
  animation: mobile-fade-up 0.24s ease;
  display: flex;
}

html[data-mobile="1"] .profile-menu.hidden {
  display: none !important;
}

html[data-mobile="1"] #screen-share-menu:not(.hidden) {
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(16px + var(--mobile-safe-b)) !important;
  transform: translateX(-50%) !important;
  width: min(92vw, 340px);
  max-width: 92vw;
  z-index: 240;
}

html[data-mobile="1"] .members-overlay.visible {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  animation: mobile-fade 0.2s ease;
}

html[data-mobile="1"] .members-panel {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  width: min(88vw, 340px);
  height: 100dvh;
  margin: 0;
  border-radius: 18px 0 0 18px;
  z-index: 100;
  transform: translateX(104%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  background: #10151c;
}

html[data-mobile="1"] .members-panel.hidden { display: none !important; }

html[data-mobile="1"] .members-panel.mobile-visible {
  display: flex !important;
  transform: translateX(0);
}

html[data-mobile="1"] .members-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--mobile-safe-t)) 14px 12px;
}

html[data-mobile="1"] .mobile-members-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef1f4;
}

html[data-mobile="1"] .modal-card,
html[data-mobile="1"] .server-create-card,
html[data-mobile="1"] .channel-editor-card,
html[data-mobile="1"] .app-settings-card {
  width: min(100vw - 16px, 560px) !important;
  min-width: 0 !important;
  max-height: calc(100dvh - 20px);
}

html[data-mobile="1"] .ch-editor-layout,
html[data-mobile="1"] .app-settings-layout,
html[data-mobile="1"] .server-settings-layout {
  grid-template-columns: 1fr !important;
}

html[data-mobile="1"] #voisio-version-badge { display: none; }

@keyframes mobile-slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}

@keyframes mobile-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes mobile-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Android WebView leaves opacity animations stuck at 0 after the splash. */
html[data-native="1"] #app,
html[data-native="1"] #main,
html[data-native="1"] #main > *,
html[data-native="1"] .sidebar,
html[data-native="1"] .content,
html[data-native="1"] .content-body,
html[data-native="1"] .chat.panel,
html[data-native="1"] .list .item,
html[data-native="1"] .mobile-server-card,
html[data-native="1"] .mobile-tabbar {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html[data-mobile="1"] *,
  html[data-mobile="1"] *::before,
  html[data-mobile="1"] *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
