/* ============================================================
   FORGE — forge_app_mobile.css
   Phone layout, see forge_app_mobile.js. Loads last.
   ============================================================ */

.mobile-back,
.mobile-panel-back,
.mobile-backdrop { display: none; }

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  #page-app {
    position: relative;
    width: 100vw;
    height: 100dvh;
  }

  /* ── One screen at a time ── */
  .sidebar {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    border-right: none;
  }
  .main-content {
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  #page-app.mobile-chat .main-content { transform: none; }

  .mobile-back { display: flex; flex-shrink: 0; margin-left: -8px; }
  .topbar { padding: 0 8px; }
  .topbar-ch-desc { display: none; }
  .topbar-ch-name {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .topbar-actions { flex-shrink: 0; margin-left: auto; }

  /* ── Members slide over the chat ── */
  .members-panel,
  .members-panel.collapsed {
    display: flex;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 300px);
    min-width: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  #page-app.mobile-members .members-panel { transform: none; }
  #page-app.mobile-members .mobile-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.5);
  }

  /* ── Bigger targets, and nothing that needs a mouse ── */
  .ch-item { min-height: 40px; }
  .sidebar-nav-item { min-height: 40px; }
  .ch-item-actions { display: flex; }
  .message.touch-active .msg-actions { opacity: 1; pointer-events: all; }
  .chat-input { font-size: 16px; }
  #more-menu {
    left: 8px !important;
    right: 8px;
    min-width: 0 !important;
  }

  /* ── Settings, profile and server settings: tabs on top, page below ── */
  .settings-layout,
  .profile-panel-layout {
    flex-direction: column;
    height: 100dvh;
  }
  .settings-nav,
  .profile-panel-nav {
    flex-direction: row;
    align-items: center;
    width: 100%;
    min-width: 0;
    height: auto;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .settings-nav-item,
  .profile-nav-item {
    flex-shrink: 0;
    white-space: nowrap;
    margin: 0;
  }
  .settings-nav-section,
  .settings-nav-section-label,
  .settings-nav-divider,
  .settings-nav-version,
  .profile-nav-section-label { display: none; }
  /* A back arrow stays at the left of the tabs in place of the close button at the end */
  .profile-close-yellow-btn,
  .settings-nav-item.danger[onclick^="close"] { display: none; }
  .mobile-panel-back {
    display: flex;
    position: sticky;
    left: -8px;
    z-index: 1;
    flex-shrink: 0;
    align-self: stretch;
    width: auto;
    height: auto;
    margin: -8px 0 -8px -8px;
    padding: 0 8px 0 10px;
    border-radius: 0;
    color: var(--text-primary);
    background: var(--bg-well);
    box-shadow: 6px 0 8px -4px rgba(0, 0, 0, 0.5);
  }
  .profile-two-col { grid-template-columns: minmax(0, 1fr); }
  .profile-page.active { overflow-y: auto; }
  .settings-content,
  .profile-panel-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
  }
  .settings-page-with-preview.active { flex-direction: column; height: auto; }

  /* ── Popups fit the screen ── */
  .modal-auth,
  .modal-dialog,
  .modal-create-server,
  .discover-modal-inner {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
  /* The close and back buttons stay at the top while a popup scrolls */
  .modal-close-btn {
    position: sticky;
    top: 8px;
    z-index: 5;
    margin: 8px 8px -38px auto;
    background: var(--bg-card);
  }
  .css-back {
    position: sticky;
    top: 0;
    z-index: 5;
    cursor: pointer;
    background: var(--bg-panel);
  }

  /* ── Video stacks instead of sitting side by side ── */
  .voice-stage { grid-template-columns: minmax(0, 1fr); }
}
